|
2 | 2 | using System.Text; |
3 | 3 | using CliWrap; |
4 | 4 | using CliWrap.Exceptions; |
5 | | -using FluentAssertions; |
6 | | -using FluentAssertions.Execution; |
7 | 5 | using Serilog.Settings.Configuration.Tests.Support; |
8 | 6 | using Xunit.Abstractions; |
9 | 7 |
|
10 | 8 | namespace Serilog.Settings.Configuration.Tests; |
11 | 9 |
|
12 | 10 | [Trait("Category", "Integration")] |
13 | | -public sealed class PublishSingleFileTests : IDisposable, IClassFixture<TestApp> |
| 11 | +public sealed class PublishSingleFileTests : IClassFixture<TestApp> |
14 | 12 | { |
15 | 13 | readonly ITestOutputHelper _outputHelper; |
16 | 14 | readonly TestApp _testApp; |
17 | | - readonly AssertionScope _scope; |
18 | 15 |
|
19 | 16 | public PublishSingleFileTests(ITestOutputHelper outputHelper, TestApp testApp) |
20 | 17 | { |
21 | 18 | _outputHelper = outputHelper; |
22 | 19 | _testApp = testApp; |
23 | | - _scope = new AssertionScope(); |
24 | | - } |
25 | | - |
26 | | - public void Dispose() |
27 | | - { |
28 | | - _scope.Dispose(); |
29 | 20 | } |
30 | 21 |
|
31 | 22 | [Theory] |
32 | 23 | [ClassData(typeof(PublishModeTheoryData))] |
33 | 24 | public async Task RunTestApp_NoUsingAndNoAssembly(PublishMode publishMode) |
34 | 25 | { |
35 | 26 | var (isSingleFile, stdOut, stdErr) = await RunTestAppAsync(publishMode); |
36 | | - stdOut.Should().Be(isSingleFile ? "Expected exception" : "(Main thread) [Information] Expected success"); |
37 | | - stdErr.Should().BeEmpty(); |
| 27 | + Assert.Equal(stdOut, isSingleFile ? "Expected exception" : "(Main thread) [Information] Expected success"); |
| 28 | + Assert.Empty(stdErr); |
38 | 29 | } |
39 | 30 |
|
40 | 31 | [Theory] |
41 | 32 | [ClassData(typeof(PublishModeTheoryData))] |
42 | 33 | public async Task RunTestApp_UsingConsole(PublishMode publishMode) |
43 | 34 | { |
44 | 35 | var (isSingleFile, stdOut, stdErr) = await RunTestAppAsync(publishMode, "--using-console"); |
45 | | - stdOut.Should().Be(isSingleFile ? "() [Information] Expected success" : "(Main thread) [Information] Expected success"); |
| 36 | + Assert.Equal(stdOut, isSingleFile ? "() [Information] Expected success" : "(Main thread) [Information] Expected success"); |
46 | 37 | if (isSingleFile) |
47 | | - stdErr.Should().Contain("Unable to find a method called WithThreadName"); |
| 38 | + Assert.Contains("Unable to find a method called WithThreadName", stdErr); |
48 | 39 | else |
49 | | - stdErr.Should().BeEmpty(); |
| 40 | + Assert.Empty(stdErr); |
50 | 41 | } |
51 | 42 |
|
52 | 43 | [Theory] |
53 | 44 | [ClassData(typeof(PublishModeTheoryData))] |
54 | 45 | public async Task RunTestApp_UsingThread(PublishMode publishMode) |
55 | 46 | { |
56 | 47 | var (isSingleFile, stdOut, stdErr) = await RunTestAppAsync(publishMode, "--using-thread"); |
57 | | - stdOut.Should().Be(isSingleFile ? "" : "(Main thread) [Information] Expected success"); |
| 48 | + Assert.Equal(stdOut, isSingleFile ? "" : "(Main thread) [Information] Expected success"); |
58 | 49 | if (isSingleFile) |
59 | | - stdErr.Should().Contain("Unable to find a method called Console"); |
| 50 | + Assert.Contains("Unable to find a method called Console", stdErr); |
60 | 51 | else |
61 | | - stdErr.Should().BeEmpty(); |
| 52 | + Assert.Empty(stdErr); |
62 | 53 | } |
63 | 54 |
|
64 | 55 | [Theory] |
65 | 56 | [ClassData(typeof(PublishModeTheoryData))] |
66 | 57 | public async Task RunTestApp_AssemblyThread(PublishMode publishMode) |
67 | 58 | { |
68 | 59 | var (_, stdOut, stdErr) = await RunTestAppAsync(publishMode, "--assembly-thread"); |
69 | | - stdOut.Should().BeEmpty(); |
70 | | - stdErr.Should().Contain("Unable to find a method called Console"); |
| 60 | + Assert.Empty(stdOut); |
| 61 | + Assert.Contains("Unable to find a method called Console", stdErr); |
71 | 62 | } |
72 | 63 |
|
73 | 64 | [Theory] |
74 | 65 | [ClassData(typeof(PublishModeTheoryData))] |
75 | 66 | public async Task RunTestApp_AssemblyConsole(PublishMode publishMode) |
76 | 67 | { |
77 | 68 | var (_, stdOut, stdErr) = await RunTestAppAsync(publishMode, "--assembly-console"); |
78 | | - stdOut.Should().Be("() [Information] Expected success"); |
79 | | - stdErr.Should().Contain("Unable to find a method called WithThreadName"); |
| 69 | + Assert.Equal("() [Information] Expected success", stdOut); |
| 70 | + Assert.Contains("Unable to find a method called WithThreadName", stdErr); |
80 | 71 | } |
81 | 72 |
|
82 | 73 | [Theory] |
83 | 74 | [ClassData(typeof(PublishModeAndStrategyTheoryData))] |
84 | 75 | public async Task RunTestApp_ConsoleAndThread(PublishMode publishMode, string strategy) |
85 | 76 | { |
86 | 77 | var (_, stdOut, stdErr) = await RunTestAppAsync(publishMode, $"--{strategy}-console", $"--{strategy}-thread"); |
87 | | - stdOut.Should().Be("(Main thread) [Information] Expected success"); |
88 | | - stdErr.Should().BeEmpty(); |
| 78 | + Assert.Equal("(Main thread) [Information] Expected success", stdOut); |
| 79 | + Assert.Empty(stdErr); |
89 | 80 | } |
90 | 81 |
|
91 | 82 | [Theory] |
92 | 83 | [ClassData(typeof(PublishModeTheoryData))] |
93 | 84 | public async Task RunTestApp_ConfigureMinimumLevelOnly(PublishMode publishMode) |
94 | 85 | { |
95 | 86 | var (_, stdOut, stdErr) = await RunTestAppAsync(publishMode, "--minimum-level-only"); |
96 | | - stdOut.Should().Be("(Main thread) [Information] Expected success"); |
97 | | - stdErr.Should().BeEmpty(); |
| 87 | + Assert.Equal("(Main thread) [Information] Expected success", stdOut); |
| 88 | + Assert.Empty(stdErr); |
98 | 89 | } |
99 | 90 |
|
100 | 91 | async Task<(bool IsSingleFile, string StdOut, string StdErr)> RunTestAppAsync(PublishMode publishMode, params string[] args) |
|
0 commit comments