1
1
using System ;
2
2
using System . Collections . Generic ;
3
+ using System . Linq ;
3
4
using System . Threading ;
4
5
using Akka . Actor ;
5
6
using Akka . Configuration ;
6
7
using Akka . Event ;
7
8
using Akka . TestKit ;
9
+ using Akka . Tests . Shared . Internals ;
8
10
using Xunit ;
9
11
using Xunit . Abstractions ;
10
12
using FluentAssertions ;
@@ -26,25 +28,40 @@ public LoggerSpec(ITestOutputHelper output) : base(Config, output)
26
28
[ Fact ]
27
29
public void TestOutputLogger_WithBadFormattingMustNotThrow ( )
28
30
{
31
+ var events = new List < LogEvent > ( ) ;
32
+
29
33
// Need to wait until TestOutputLogger initializes
30
34
Thread . Sleep ( 200 ) ;
31
35
Sys . EventStream . Subscribe ( TestActor , typeof ( LogEvent ) ) ;
32
36
33
37
Sys . Log . Error ( new FakeException ( "BOOM" ) , Case . t , Case . p ) ;
34
- ExpectMsg < Error > ( ) . Cause . Should ( ) . BeOfType < FakeException > ( ) ;
35
- ExpectMsg < Error > ( ) . Cause . Should ( ) . BeOfType < AggregateException > ( ) ;
38
+ events . Add ( ExpectMsg < Error > ( ) ) ;
39
+ events . Add ( ExpectMsg < Error > ( ) ) ;
40
+
41
+ events . All ( e => e is Error ) . Should ( ) . BeTrue ( ) ;
42
+ events . Select ( e => e . Cause ) . Any ( c => c is FakeException ) . Should ( ) . BeTrue ( ) ;
43
+ events . Select ( e => e . Cause ) . Any ( c => c is AggregateException ) . Should ( ) . BeTrue ( ) ;
36
44
45
+ events . Clear ( ) ;
37
46
Sys . Log . Warning ( Case . t , Case . p ) ;
38
- ExpectMsg < Warning > ( ) ;
39
- ExpectMsg < Error > ( ) . Cause . Should ( ) . BeOfType < FormatException > ( ) ;
47
+ events . Add ( ExpectMsg < LogEvent > ( ) ) ;
48
+ events . Add ( ExpectMsg < LogEvent > ( ) ) ;
49
+ events . Any ( e => e is Warning ) . Should ( ) . BeTrue ( ) ;
50
+ events . First ( e => e is Error ) . Cause . Should ( ) . BeOfType < FormatException > ( ) ;
40
51
52
+ events . Clear ( ) ;
41
53
Sys . Log . Info ( Case . t , Case . p ) ;
42
- ExpectMsg < Info > ( ) ;
43
- ExpectMsg < Error > ( ) . Cause . Should ( ) . BeOfType < FormatException > ( ) ;
54
+ events . Add ( ExpectMsg < LogEvent > ( ) ) ;
55
+ events . Add ( ExpectMsg < LogEvent > ( ) ) ;
56
+ events . Any ( e => e is Info ) . Should ( ) . BeTrue ( ) ;
57
+ events . First ( e => e is Error ) . Cause . Should ( ) . BeOfType < FormatException > ( ) ;
44
58
59
+ events . Clear ( ) ;
45
60
Sys . Log . Debug ( Case . t , Case . p ) ;
46
- ExpectMsg < Debug > ( ) ;
47
- ExpectMsg < Error > ( ) . Cause . Should ( ) . BeOfType < FormatException > ( ) ;
61
+ events . Add ( ExpectMsg < LogEvent > ( ) ) ;
62
+ events . Add ( ExpectMsg < LogEvent > ( ) ) ;
63
+ events . Any ( e => e is Debug ) . Should ( ) . BeTrue ( ) ;
64
+ events . First ( e => e is Error ) . Cause . Should ( ) . BeOfType < FormatException > ( ) ;
48
65
}
49
66
50
67
[ Fact ]
0 commit comments