|
4 | 4 | [](https://www.fuget.org/packages/Xunit.Microsoft.DependencyInjection)
|
5 | 5 |
|
6 | 6 | # Xunit Dependency Injection framework
|
7 |
| -Xunit does not come with any built-in dependency injection features, therefore developers have to come up with their own solution to recruit their favourite dependency injection frameworks in their tests. |
| 7 | +Xunit does not come with any built-in dependency injection features, therefore developers have to come up with a solution to recruit their favourite dependency injection framework in their tests. |
8 | 8 |
|
9 |
| -This library brings in Microsoft's dependency injection container to Xunit by leveraging fixtures. |
| 9 | +This library brings in Microsoft's dependency injection container to Xunit scope by leveraging Xunit fixtures. |
10 | 10 |
|
11 |
| -## Get started |
| 11 | +## Getting started |
12 | 12 |
|
13 | 13 | ### Nuget package
|
14 |
| -First add the nuget package to your Xunit project: |
| 14 | +First add the following [nuget package](https://www.nuget.org/packages/Xunit.Microsoft.DependencyInjection/) to your Xunit project: |
15 | 15 |
|
16 | 16 | ```
|
17 | 17 | Install-Package Xunit.Microsoft.DependencyInjection
|
18 | 18 | ```
|
19 | 19 |
|
20 | 20 | ### Setup your fixture
|
21 | 21 |
|
22 |
| -There is an abstract class called ```Xunit.Microsoft.DependencyInjection.Abstracts.TestBedFixture``` which contains the necessary functionalities to add services and configurations to Microsoft's dependency injection container. Your concrete test fixture class derived from this abstract class must implement the following two abstract methods: |
| 22 | +The abstract class of `Xunit.Microsoft.DependencyInjection.Abstracts.TestBedFixture` contains the necessary functionalities to add services and configurations to Microsoft's dependency injection container. Your concrete test fixture class must derive from this abstract class and implement the following two abstract methods: |
23 | 23 |
|
24 | 24 | ```csharp
|
25 |
| -protected abstract string GetConfigurationFile(); |
| 25 | +protected abstract IEnumerable<string> GetConfigurationFiles(); |
26 | 26 | protected abstract void AddServices(IServiceCollection services, IConfiguration configuration);
|
27 | 27 | ```
|
28 | 28 |
|
29 |
| -```GetConfigurationFile(...)``` method returns the name of the configuration file in your Xunit test project. ```AddServices(...)``` is used to wire up services. |
| 29 | +`GetConfigurationFiles(...)` method returns a collection of the configuration files in your Xunit test project to the framework. `AddServices(...)` method must be used to wire up the implemented services. |
30 | 30 |
|
31 | 31 | ### Access the wired up services
|
32 | 32 | There are two method that you can use to access the wired up service depending on your context:
|
|
0 commit comments