Skip to content

Commit 151311a

Browse files
authored
Provide Microsoft.Extensions.DependencyInjection.Specification.Tests package readme (#106317)
1 parent 03c4213 commit 151311a

File tree

2 files changed

+68
-2
lines changed

2 files changed

+68
-2
lines changed

src/libraries/Microsoft.Extensions.DependencyInjection.Specification.Tests/src/Microsoft.Extensions.DependencyInjection.Specification.Tests.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
<PackageDescription>Suite of xUnit.net tests to check for container compatibility with Microsoft.Extensions.DependencyInjection.</PackageDescription>
1616
<!-- this assembly doesn't need to be binplaced -->
1717
<EnableBinPlacing>false</EnableBinPlacing>
18-
<!-- TODO: Add package README file: https://github.com/dotnet/runtime/issues/99358 -->
19-
<EnableDefaultPackageReadmeFile>false</EnableDefaultPackageReadmeFile>
2018
</PropertyGroup>
2119

2220
<ItemGroup>
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
## About
2+
3+
Provides a suite of xUnit.net tests designed to ensure compatibility with the `Microsoft.Extensions.DependencyInjection` framework.
4+
5+
This package is intended for developers implementing their own Dependency Injection (DI) containers, allowing them to verify that their implementations conform to the expected behavior of the Microsoft Dependency Injection framework.
6+
7+
## Key Features
8+
9+
<!-- The key features of this package -->
10+
11+
* Comprehensive suite of tests to validate DI container compatibility with the Microsoft Dependency Injection framework.
12+
* Includes fakes and mocks (`Microsoft.Extensions.DependencyInjection.Specification.Fakes`) for testing common scenarios.
13+
14+
## How to Use
15+
16+
<!-- A compelling example on how to use this package with code, as well as any specific guidelines for when to use the package -->
17+
18+
To utilize the `Microsoft.Extensions.DependencyInjection.Specification.Tests` in a custom DI container implementation, create a test project and include this package as a dependency.
19+
Then, run the specification tests against the DI container to validate its compatibility with the `Microsoft.Extensions.DependencyInjection` framework.
20+
21+
1. Start by creating a test project to run the specification tests.
22+
2. Add the following NuGet packages to the test project:
23+
24+
* Microsoft.Extensions.DependencyInjection.Specification.Tests
25+
* xunit
26+
27+
3. Add the custom DI container package (e.g., `MyCustomDI`)
28+
4. In the test project, create a class that inherits from `DependencyInjectionSpecificationTests` provided by the `Microsoft.Extensions.DependencyInjection.Specification.Tests` package.
29+
30+
Override the `CreateServiceProvider` method to return an instance of the DI container's service provider.
31+
32+
```csharp
33+
using Microsoft.Extensions.DependencyInjection;
34+
using Microsoft.Extensions.DependencyInjection.Specification.Tests;
35+
using Xunit;
36+
using MyCustomDI;
37+
38+
public class MyCustomDIContainerTests : DependencyInjectionSpecificationTests
39+
{
40+
protected override IServiceProvider CreateServiceProvider(IServiceCollection serviceCollection)
41+
{
42+
// Create an instance of your custom DI container and build the service provider
43+
return MyCustomDIContainer.BuildServiceProvider(serviceCollection);
44+
}
45+
}
46+
```
47+
48+
5. Run the tests to validate that the custom DI container behaves according to the Microsoft Dependency Injection specifications.
49+
50+
## Main Types
51+
52+
<!-- The main types provided in this library -->
53+
54+
The main types provided by this library are:
55+
56+
* `Microsoft.Extensions.DependencyInjection.Specification.DependencyInjectionSpecificationTests`
57+
* `Microsoft.Extensions.DependencyInjection.Specification.KeyedDependencyInjectionSpecificationTests`
58+
59+
<!-- ## Additional Documentation -->
60+
61+
<!-- Links to further documentation. Remove conceptual documentation if not available for the library. -->
62+
63+
## Feedback & Contributing
64+
65+
<!-- How to provide feedback on this package and contribute to it -->
66+
67+
Microsoft.Extensions.DependencyInjection.Specification.Tests is released as open source under the [MIT license](https://licenses.nuget.org/MIT).
68+
Bug reports and contributions are welcome at [the GitHub repository](https://github.com/dotnet/runtime).

0 commit comments

Comments
 (0)