Skip to content

Commit 32cb3a9

Browse files
#140: Add Sequence Tests
1 parent f382a9d commit 32cb3a9

7 files changed

+324
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[
2+
{
3+
Sequence: 0,
4+
LogLevel: Error,
5+
FormattedMessage: This is the fifth log.
6+
},
7+
{
8+
Sequence: 1,
9+
LogLevel: Critical,
10+
FormattedMessage: This is the sixth log.
11+
},
12+
{
13+
Sequence: 6,
14+
LogLevel: Error,
15+
FormattedMessage: This is the eleventh log.
16+
},
17+
{
18+
Sequence: 7,
19+
LogLevel: Critical,
20+
FormattedMessage: This is the twelfth log.
21+
}
22+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
[
2+
{
3+
Sequence: 0,
4+
LogLevel: Information,
5+
FormattedMessage: This is the first log.
6+
},
7+
{
8+
Sequence: 2,
9+
LogLevel: Warning,
10+
FormattedMessage: This is the third log.
11+
},
12+
{
13+
Sequence: 4,
14+
LogLevel: Error,
15+
FormattedMessage: This is the fifth log.
16+
},
17+
{
18+
Sequence: 5,
19+
LogLevel: Critical,
20+
FormattedMessage: This is the sixth log.
21+
},
22+
{
23+
Sequence: 6,
24+
LogLevel: Information,
25+
FormattedMessage: This is the seventh log.
26+
},
27+
{
28+
Sequence: 8,
29+
LogLevel: Warning,
30+
FormattedMessage: This is the ninth log.
31+
},
32+
{
33+
Sequence: 10,
34+
LogLevel: Error,
35+
FormattedMessage: This is the eleventh log.
36+
},
37+
{
38+
Sequence: 11,
39+
LogLevel: Critical,
40+
FormattedMessage: This is the twelfth log.
41+
}
42+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
[
2+
{
3+
Sequence: 0,
4+
LogLevel: Information,
5+
FormattedMessage: This is the first log.
6+
},
7+
{
8+
Sequence: 1,
9+
LogLevel: Trace,
10+
FormattedMessage: This is the second log.
11+
},
12+
{
13+
Sequence: 2,
14+
LogLevel: Warning,
15+
FormattedMessage: This is the third log.
16+
},
17+
{
18+
Sequence: 3,
19+
LogLevel: Debug,
20+
FormattedMessage: This is the fourth log.
21+
},
22+
{
23+
Sequence: 4,
24+
LogLevel: Error,
25+
FormattedMessage: This is the fifth log.
26+
},
27+
{
28+
Sequence: 5,
29+
LogLevel: Critical,
30+
FormattedMessage: This is the sixth log.
31+
},
32+
{
33+
Sequence: 6,
34+
LogLevel: Information,
35+
FormattedMessage: This is the seventh log.
36+
},
37+
{
38+
Sequence: 7,
39+
LogLevel: Trace,
40+
FormattedMessage: This is the eighth log.
41+
},
42+
{
43+
Sequence: 8,
44+
LogLevel: Warning,
45+
FormattedMessage: This is the ninth log.
46+
},
47+
{
48+
Sequence: 9,
49+
LogLevel: Debug,
50+
FormattedMessage: This is the tenth log.
51+
},
52+
{
53+
Sequence: 10,
54+
LogLevel: Error,
55+
FormattedMessage: This is the eleventh log.
56+
},
57+
{
58+
Sequence: 11,
59+
LogLevel: Critical,
60+
FormattedMessage: This is the twelfth log.
61+
}
62+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[
2+
{
3+
Sequence: 0,
4+
LogLevel: Error,
5+
FormattedMessage: This is the fifth log.
6+
},
7+
{
8+
Sequence: 1,
9+
LogLevel: Critical,
10+
FormattedMessage: This is the sixth log.
11+
},
12+
{
13+
Sequence: 2,
14+
LogLevel: Error,
15+
FormattedMessage: This is the eleventh log.
16+
},
17+
{
18+
Sequence: 3,
19+
LogLevel: Critical,
20+
FormattedMessage: This is the twelfth log.
21+
}
22+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
[
2+
{
3+
Sequence: 0,
4+
LogLevel: Information,
5+
FormattedMessage: This is the first log.
6+
},
7+
{
8+
Sequence: 1,
9+
LogLevel: Warning,
10+
FormattedMessage: This is the third log.
11+
},
12+
{
13+
Sequence: 2,
14+
LogLevel: Error,
15+
FormattedMessage: This is the fifth log.
16+
},
17+
{
18+
Sequence: 3,
19+
LogLevel: Critical,
20+
FormattedMessage: This is the sixth log.
21+
},
22+
{
23+
Sequence: 4,
24+
LogLevel: Information,
25+
FormattedMessage: This is the seventh log.
26+
},
27+
{
28+
Sequence: 5,
29+
LogLevel: Warning,
30+
FormattedMessage: This is the ninth log.
31+
},
32+
{
33+
Sequence: 6,
34+
LogLevel: Error,
35+
FormattedMessage: This is the eleventh log.
36+
},
37+
{
38+
Sequence: 7,
39+
LogLevel: Critical,
40+
FormattedMessage: This is the twelfth log.
41+
}
42+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
[
2+
{
3+
Sequence: 0,
4+
LogLevel: Information,
5+
FormattedMessage: This is the first log.
6+
},
7+
{
8+
Sequence: 1,
9+
LogLevel: Trace,
10+
FormattedMessage: This is the second log.
11+
},
12+
{
13+
Sequence: 2,
14+
LogLevel: Warning,
15+
FormattedMessage: This is the third log.
16+
},
17+
{
18+
Sequence: 3,
19+
LogLevel: Debug,
20+
FormattedMessage: This is the fourth log.
21+
},
22+
{
23+
Sequence: 4,
24+
LogLevel: Error,
25+
FormattedMessage: This is the fifth log.
26+
},
27+
{
28+
Sequence: 5,
29+
LogLevel: Critical,
30+
FormattedMessage: This is the sixth log.
31+
},
32+
{
33+
Sequence: 6,
34+
LogLevel: Information,
35+
FormattedMessage: This is the seventh log.
36+
},
37+
{
38+
Sequence: 7,
39+
LogLevel: Trace,
40+
FormattedMessage: This is the eighth log.
41+
},
42+
{
43+
Sequence: 8,
44+
LogLevel: Warning,
45+
FormattedMessage: This is the ninth log.
46+
},
47+
{
48+
Sequence: 9,
49+
LogLevel: Debug,
50+
FormattedMessage: This is the tenth log.
51+
},
52+
{
53+
Sequence: 10,
54+
LogLevel: Error,
55+
FormattedMessage: This is the eleventh log.
56+
},
57+
{
58+
Sequence: 11,
59+
LogLevel: Critical,
60+
FormattedMessage: This is the twelfth log.
61+
}
62+
]
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
using System.Collections.Generic;
2+
using System.Linq;
3+
using System.Threading.Tasks;
4+
using Microsoft.Extensions.Logging;
5+
using NUnit.Framework;
6+
using Stravaig.Extensions.Logging.Diagnostics.Verify;
7+
using VerifyNUnit;
8+
using VerifyTests;
9+
10+
namespace Stravaig.Extensions.Logging.Diagnostics.Tests.Verify;
11+
12+
[TestFixture]
13+
public class VerifySequenceTests
14+
{
15+
[Test]
16+
[TestCase(LogLevel.Trace)]
17+
[TestCase(LogLevel.Information)]
18+
[TestCase(LogLevel.Error)]
19+
public async Task ConsecutiveSequenceTest(LogLevel minLevel)
20+
{
21+
var logs = GetLogs().Where(l => l.LogLevel >= minLevel);
22+
VerifySettings verifySettings = new VerifySettings()
23+
.AddCapturedLogs(new LoggingCaptureVerifySettings()
24+
{
25+
Message = MessageSetting.Formatted,
26+
Sequence = Sequence.ShowAsConsecutive,
27+
CategoryName = false,
28+
});
29+
verifySettings.UseParameters(minLevel);
30+
31+
await Verifier.Verify(logs, verifySettings);
32+
}
33+
34+
[Test]
35+
[TestCase(LogLevel.Trace)]
36+
[TestCase(LogLevel.Information)]
37+
[TestCase(LogLevel.Error)]
38+
public async Task CadenceSequenceTest(LogLevel minLevel)
39+
{
40+
var logs = GetLogs().Where(l => l.LogLevel >= minLevel);
41+
VerifySettings verifySettings = new VerifySettings()
42+
.AddCapturedLogs(new LoggingCaptureVerifySettings()
43+
{
44+
Message = MessageSetting.Formatted,
45+
Sequence = Sequence.ShowAsCadence,
46+
CategoryName = false,
47+
});
48+
verifySettings.UseParameters(minLevel);
49+
50+
await Verifier.Verify(logs, verifySettings);
51+
}
52+
53+
private IReadOnlyList<LogEntry> GetLogs()
54+
{
55+
var logger = new TestCaptureLogger<VerifySequenceTests>();
56+
logger.LogInformation("This is the first log.");
57+
logger.LogTrace("This is the second log.");
58+
logger.LogWarning("This is the third log.");
59+
logger.LogDebug("This is the fourth log.");
60+
logger.LogError("This is the fifth log.");
61+
logger.LogCritical("This is the sixth log.");
62+
63+
logger.LogInformation("This is the seventh log.");
64+
logger.LogTrace("This is the eighth log.");
65+
logger.LogWarning("This is the ninth log.");
66+
logger.LogDebug("This is the tenth log.");
67+
logger.LogError("This is the eleventh log.");
68+
logger.LogCritical("This is the twelfth log.");
69+
70+
return logger.GetLogs();
71+
}
72+
}

0 commit comments

Comments
 (0)