Skip to content

Commit f382a9d

Browse files
#140: Test verify
1 parent 473d81e commit f382a9d

9 files changed

+166
-175
lines changed

src/Stravaig.Extensions.Logging.Diagnostics.Tests/Verify/VerifyDefaultSettingsTests.TestExplicitDefaultAsync.verified.txt

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,31 @@
33
Sequence: 0,
44
LogLevel: Information,
55
CategoryName: Stravaig.Extensions.Logging.Diagnostics.Tests.Verify.VerifyDefaultSettingsTests,
6-
FormattedMessage: This is the first default log message
6+
MessageTemplate: This is the first default log message
77
},
88
{
99
Sequence: 1,
1010
LogLevel: Warning,
1111
CategoryName: Stravaig.Extensions.Logging.Diagnostics.Tests.Verify.VerifyDefaultSettingsTests,
12-
FormattedMessage: This is a warning
12+
MessageTemplate: This is a warning
1313
},
1414
{
1515
Sequence: 2,
1616
LogLevel: Error,
1717
CategoryName: Stravaig.Extensions.Logging.Diagnostics.Tests.Verify.VerifyDefaultSettingsTests,
18-
FormattedMessage: An exception was thrown. See the exception for details.,
18+
MessageTemplate: An exception was thrown. See the exception for details.,
1919
Exception: {
20-
Message: I'm a fake exception to be put in the log.,
2120
Type: System.ApplicationException
2221
}
2322
},
2423
{
2524
Sequence: 3,
2625
LogLevel: Critical,
2726
CategoryName: Stravaig.Extensions.Logging.Diagnostics.Tests.Verify.VerifyDefaultSettingsTests,
28-
FormattedMessage: An exception was thrown, which caused another exception to be thrown.,
27+
MessageTemplate: An exception was thrown, which caused another exception to be thrown.,
2928
Exception: {
30-
Message: An application exception happened,
3129
Type: System.ApplicationException,
3230
InnerException: {
33-
Message: An invalid operation happened.,
3431
Type: System.InvalidOperationException
3532
}
3633
}

src/Stravaig.Extensions.Logging.Diagnostics.Tests/Verify/VerifyDefaultSettingsTests.TestImplicitDefaultAwait.verified.txt

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,31 @@
33
Sequence: 0,
44
LogLevel: Information,
55
CategoryName: Stravaig.Extensions.Logging.Diagnostics.Tests.Verify.VerifyDefaultSettingsTests,
6-
FormattedMessage: This is the first default log message
6+
MessageTemplate: This is the first default log message
77
},
88
{
99
Sequence: 1,
1010
LogLevel: Warning,
1111
CategoryName: Stravaig.Extensions.Logging.Diagnostics.Tests.Verify.VerifyDefaultSettingsTests,
12-
FormattedMessage: This is a warning
12+
MessageTemplate: This is a warning
1313
},
1414
{
1515
Sequence: 2,
1616
LogLevel: Error,
1717
CategoryName: Stravaig.Extensions.Logging.Diagnostics.Tests.Verify.VerifyDefaultSettingsTests,
18-
FormattedMessage: An exception was thrown. See the exception for details.,
18+
MessageTemplate: An exception was thrown. See the exception for details.,
1919
Exception: {
20-
Message: I'm a fake exception to be put in the log.,
2120
Type: System.ApplicationException
2221
}
2322
},
2423
{
2524
Sequence: 3,
2625
LogLevel: Critical,
2726
CategoryName: Stravaig.Extensions.Logging.Diagnostics.Tests.Verify.VerifyDefaultSettingsTests,
28-
FormattedMessage: An exception was thrown, which caused another exception to be thrown.,
27+
MessageTemplate: An exception was thrown, which caused another exception to be thrown.,
2928
Exception: {
30-
Message: An application exception happened,
3129
Type: System.ApplicationException,
3230
InnerException: {
33-
Message: An invalid operation happened.,
3431
Type: System.InvalidOperationException
3532
}
3633
}

src/Stravaig.Extensions.Logging.Diagnostics.Tests/Verify/VerifyDefaultSettingsTests.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,16 @@ public class VerifyDefaultSettingsTests
1717
public async Task TestExplicitDefaultAsync()
1818
{
1919
var settings = new VerifySettings()
20-
.AddStravaigTests();
20+
.AddCapturedLogs();
2121
var logs = GetLogEntries();
2222
await Verifier.Verify(logs, settings);
2323
}
2424

2525
[Test]
2626
public async Task TestImplicitDefaultAwait()
2727
{
28-
// The settings are added as part of the module initialiser
28+
// The settings are added as part of the module initialiser, so no
29+
// verify settings object is added to the Verify method.
2930
var logs = GetLogEntries();
3031
await Verifier.Verify(logs);
3132
}

src/Stravaig.Extensions.Logging.Diagnostics.Tests/Verify/VerifyLogConverterSettingsTests.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,14 @@ public async Task TestPropertiesAsync()
1616
var logger = new TestCaptureLogger<VerifyLogConverterSettingsTests>();
1717
logger.LogInformation("A {TypeOfThing} with {PropertyCount} properties.", "message", 2);
1818
var settings = new VerifySettings()
19-
.AddStravaigTests(Settings.FormattedMessage | Settings.Properties);
19+
.AddCapturedLogs(new LoggingCaptureVerifySettings
20+
{
21+
Sequence = Sequence.Hide,
22+
LogLevel = false,
23+
CategoryName = false,
24+
Message = MessageSetting.Formatted,
25+
Properties = PropertySetting.Verify,
26+
});
2027
await Verifier.Verify(logger.GetLogs(), settings);
2128
}
2229
}

src/Stravaig.Extensions.Logging.Diagnostics.Tests/Verify/VerifyLogExceptionTests.VerifyInnerExceptionsAsync.verified.txt

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,41 +5,41 @@
55
CategoryName: Stravaig.Extensions.Logging.Diagnostics.Tests.Verify.VerifyLogExceptionTests,
66
FormattedMessage: An Exception was thrown.,
77
Exception: {
8-
Message: Current depth is 5.,
98
Type: System.ApplicationException,
9+
Message: Current depth is 5.,
1010
StackTrace:
11-
at Stravaig.Extensions.Logging.Diagnostics.Tests.Verify.VerifyLogExceptionTests.ThrowAnExceptionWithInnerExceptions(Int32 depth) in {ProjectDirectory}Verify/VerifyLogExceptionTests.cs:line 43
11+
at Stravaig.Extensions.Logging.Diagnostics.Tests.Verify.VerifyLogExceptionTests.ThrowAnExceptionWithInnerExceptions(Int32 depth) in {ProjectDirectory}Verify/VerifyLogExceptionTests.cs:line 47
1212
at Stravaig.Extensions.Logging.Diagnostics.Tests.Verify.VerifyLogExceptionTests.VerifyInnerExceptionsAsync() in {ProjectDirectory}Verify/VerifyLogExceptionTests.cs:line 20,
1313
InnerException: {
14-
Message: Current depth is 4.,
1514
Type: System.ApplicationException,
15+
Message: Current depth is 4.,
1616
StackTrace:
17-
at Stravaig.Extensions.Logging.Diagnostics.Tests.Verify.VerifyLogExceptionTests.ThrowAnExceptionWithInnerExceptions(Int32 depth) in {ProjectDirectory}Verify/VerifyLogExceptionTests.cs:line 43
18-
at Stravaig.Extensions.Logging.Diagnostics.Tests.Verify.VerifyLogExceptionTests.ThrowAnExceptionWithInnerExceptions(Int32 depth) in {ProjectDirectory}Verify/VerifyLogExceptionTests.cs:line 39,
17+
at Stravaig.Extensions.Logging.Diagnostics.Tests.Verify.VerifyLogExceptionTests.ThrowAnExceptionWithInnerExceptions(Int32 depth) in {ProjectDirectory}Verify/VerifyLogExceptionTests.cs:line 47
18+
at Stravaig.Extensions.Logging.Diagnostics.Tests.Verify.VerifyLogExceptionTests.ThrowAnExceptionWithInnerExceptions(Int32 depth) in {ProjectDirectory}Verify/VerifyLogExceptionTests.cs:line 43,
1919
InnerException: {
20-
Message: Current depth is 3.,
2120
Type: System.ApplicationException,
21+
Message: Current depth is 3.,
2222
StackTrace:
23-
at Stravaig.Extensions.Logging.Diagnostics.Tests.Verify.VerifyLogExceptionTests.ThrowAnExceptionWithInnerExceptions(Int32 depth) in {ProjectDirectory}Verify/VerifyLogExceptionTests.cs:line 43
24-
at Stravaig.Extensions.Logging.Diagnostics.Tests.Verify.VerifyLogExceptionTests.ThrowAnExceptionWithInnerExceptions(Int32 depth) in {ProjectDirectory}Verify/VerifyLogExceptionTests.cs:line 39,
23+
at Stravaig.Extensions.Logging.Diagnostics.Tests.Verify.VerifyLogExceptionTests.ThrowAnExceptionWithInnerExceptions(Int32 depth) in {ProjectDirectory}Verify/VerifyLogExceptionTests.cs:line 47
24+
at Stravaig.Extensions.Logging.Diagnostics.Tests.Verify.VerifyLogExceptionTests.ThrowAnExceptionWithInnerExceptions(Int32 depth) in {ProjectDirectory}Verify/VerifyLogExceptionTests.cs:line 43,
2525
InnerException: {
26-
Message: Current depth is 2.,
2726
Type: System.ApplicationException,
27+
Message: Current depth is 2.,
2828
StackTrace:
29-
at Stravaig.Extensions.Logging.Diagnostics.Tests.Verify.VerifyLogExceptionTests.ThrowAnExceptionWithInnerExceptions(Int32 depth) in {ProjectDirectory}Verify/VerifyLogExceptionTests.cs:line 43
30-
at Stravaig.Extensions.Logging.Diagnostics.Tests.Verify.VerifyLogExceptionTests.ThrowAnExceptionWithInnerExceptions(Int32 depth) in {ProjectDirectory}Verify/VerifyLogExceptionTests.cs:line 39,
29+
at Stravaig.Extensions.Logging.Diagnostics.Tests.Verify.VerifyLogExceptionTests.ThrowAnExceptionWithInnerExceptions(Int32 depth) in {ProjectDirectory}Verify/VerifyLogExceptionTests.cs:line 47
30+
at Stravaig.Extensions.Logging.Diagnostics.Tests.Verify.VerifyLogExceptionTests.ThrowAnExceptionWithInnerExceptions(Int32 depth) in {ProjectDirectory}Verify/VerifyLogExceptionTests.cs:line 43,
3131
InnerException: {
32-
Message: Current depth is 1.,
3332
Type: System.ApplicationException,
33+
Message: Current depth is 1.,
3434
StackTrace:
35-
at Stravaig.Extensions.Logging.Diagnostics.Tests.Verify.VerifyLogExceptionTests.ThrowAnExceptionWithInnerExceptions(Int32 depth) in {ProjectDirectory}Verify/VerifyLogExceptionTests.cs:line 43
36-
at Stravaig.Extensions.Logging.Diagnostics.Tests.Verify.VerifyLogExceptionTests.ThrowAnExceptionWithInnerExceptions(Int32 depth) in {ProjectDirectory}Verify/VerifyLogExceptionTests.cs:line 39,
35+
at Stravaig.Extensions.Logging.Diagnostics.Tests.Verify.VerifyLogExceptionTests.ThrowAnExceptionWithInnerExceptions(Int32 depth) in {ProjectDirectory}Verify/VerifyLogExceptionTests.cs:line 47
36+
at Stravaig.Extensions.Logging.Diagnostics.Tests.Verify.VerifyLogExceptionTests.ThrowAnExceptionWithInnerExceptions(Int32 depth) in {ProjectDirectory}Verify/VerifyLogExceptionTests.cs:line 43,
3737
InnerException: {
38-
Message: This method throws exceptions!,
3938
Type: System.InvalidOperationException,
39+
Message: This method throws exceptions!,
4040
StackTrace:
41-
at Stravaig.Extensions.Logging.Diagnostics.Tests.Verify.VerifyLogExceptionTests.ThrowAnExceptionWithInnerExceptions(Int32 depth) in {ProjectDirectory}Verify/VerifyLogExceptionTests.cs:line 46
42-
at Stravaig.Extensions.Logging.Diagnostics.Tests.Verify.VerifyLogExceptionTests.ThrowAnExceptionWithInnerExceptions(Int32 depth) in {ProjectDirectory}Verify/VerifyLogExceptionTests.cs:line 39
41+
at Stravaig.Extensions.Logging.Diagnostics.Tests.Verify.VerifyLogExceptionTests.ThrowAnExceptionWithInnerExceptions(Int32 depth) in {ProjectDirectory}Verify/VerifyLogExceptionTests.cs:line 50
42+
at Stravaig.Extensions.Logging.Diagnostics.Tests.Verify.VerifyLogExceptionTests.ThrowAnExceptionWithInnerExceptions(Int32 depth) in {ProjectDirectory}Verify/VerifyLogExceptionTests.cs:line 43
4343
}
4444
}
4545
}

src/Stravaig.Extensions.Logging.Diagnostics.Tests/Verify/VerifyLogExceptionTests.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ public async Task VerifyInnerExceptionsAsync()
2727
var logs = logger.GetLogs();
2828

2929
VerifySettings verifySettings = new VerifySettings()
30-
.AddStravaigTests(Settings.Default | Settings.StackTrace);
30+
.AddCapturedLogs(new LoggingCaptureVerifySettings
31+
{
32+
Message = MessageSetting.Formatted,
33+
Exception = ExceptionSetting.IncludeInnerExceptions | ExceptionSetting.Message | ExceptionSetting.Type | ExceptionSetting.Message | ExceptionSetting.StackTrace,
34+
});
3135
await Verifier.Verify(logs, verifySettings);
3236
}
3337

0 commit comments

Comments
 (0)