|
1 | | -using Microsoft.Extensions.Options; |
| 1 | +using Microsoft.Extensions.Options; |
2 | 2 | using Options = Xunit.Microsoft.DependencyInjection.ExampleTests.Services.Options; |
3 | 3 |
|
4 | | -namespace Xunit.Microsoft.DependencyInjection.ExampleTests |
| 4 | +namespace Xunit.Microsoft.DependencyInjection.ExampleTests; |
| 5 | + |
| 6 | +public class IntegrationTests : TestBed<TestFixture> |
5 | 7 | { |
6 | | - public class IntegrationTests : TestBed<TestFixture> |
| 8 | + public IntegrationTests(ITestOutputHelper testOutputHelper, TestFixture fixture) |
| 9 | + : base(testOutputHelper, fixture) |
7 | 10 | { |
8 | | - public IntegrationTests(ITestOutputHelper testOutputHelper, TestFixture fixture) |
9 | | - : base(testOutputHelper, fixture) |
10 | | - { |
11 | | - } |
12 | | - |
13 | | - [Theory] |
14 | | - [InlineData(1, 2)] |
15 | | - public void Test1(int x, int y) |
16 | | - { |
17 | | - var calculator = _fixture.GetService<ICalculator>(_testOutputHelper); |
18 | | - var option = _fixture.GetService<IOptions<Options>>(_testOutputHelper); |
19 | | - var calculated = calculator?.Add(x, y); |
20 | | - var expected = option?.Value.Rate * (x + y); |
21 | | - Assert.True(expected == calculated); |
22 | | - } |
23 | | - |
24 | | - [Theory] |
25 | | - [InlineData(1, 2)] |
26 | | - public void Test2(int x, int y) |
27 | | - { |
28 | | - var calculator = _fixture.GetScopedService<ICalculator>(_testOutputHelper); |
29 | | - var option = _fixture.GetScopedService<IOptions<Options>>(_testOutputHelper); |
30 | | - var calculated = calculator?.Add(x, y); |
31 | | - var expected = option?.Value.Rate * (x + y); |
32 | | - Assert.True(expected == calculated); |
33 | | - } |
| 11 | + } |
34 | 12 |
|
35 | | - protected override void Clear() |
36 | | - { |
37 | | - } |
| 13 | + [Theory] |
| 14 | + [InlineData(1, 2)] |
| 15 | + public void Test1(int x, int y) |
| 16 | + { |
| 17 | + var calculator = _fixture.GetService<ICalculator>(_testOutputHelper); |
| 18 | + var option = _fixture.GetService<IOptions<Options>>(_testOutputHelper); |
| 19 | + var calculated = calculator?.Add(x, y); |
| 20 | + var expected = option?.Value.Rate * (x + y); |
| 21 | + Assert.True(expected == calculated); |
| 22 | + } |
38 | 23 |
|
39 | | - protected override ValueTask DisposeAsyncCore() |
40 | | - => new(); |
| 24 | + [Theory] |
| 25 | + [InlineData(1, 2)] |
| 26 | + public void Test2(int x, int y) |
| 27 | + { |
| 28 | + var calculator = _fixture.GetScopedService<ICalculator>(_testOutputHelper); |
| 29 | + var option = _fixture.GetScopedService<IOptions<Options>>(_testOutputHelper); |
| 30 | + var calculated = calculator?.Add(x, y); |
| 31 | + var expected = option?.Value.Rate * (x + y); |
| 32 | + Assert.True(expected == calculated); |
41 | 33 | } |
42 | 34 | } |
0 commit comments