Skip to content

Commit 594eb7c

Browse files
authored
[RACY] LoggerSpec TestOutputLogger Make sure that event receive order does not matter (#5015)
* Make sure that event receive order does not matter * Remove repeat attribute
1 parent bc5a2e4 commit 594eb7c

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

src/core/Akka.Tests/Loggers/LoggerSpec.cs

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Linq;
34
using System.Threading;
45
using Akka.Actor;
56
using Akka.Configuration;
67
using Akka.Event;
78
using Akka.TestKit;
9+
using Akka.Tests.Shared.Internals;
810
using Xunit;
911
using Xunit.Abstractions;
1012
using FluentAssertions;
@@ -26,25 +28,40 @@ public LoggerSpec(ITestOutputHelper output) : base(Config, output)
2628
[Fact]
2729
public void TestOutputLogger_WithBadFormattingMustNotThrow()
2830
{
31+
var events = new List<LogEvent>();
32+
2933
// Need to wait until TestOutputLogger initializes
3034
Thread.Sleep(200);
3135
Sys.EventStream.Subscribe(TestActor, typeof(LogEvent));
3236

3337
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();
3644

45+
events.Clear();
3746
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>();
4051

52+
events.Clear();
4153
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>();
4458

59+
events.Clear();
4560
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>();
4865
}
4966

5067
[Fact]

0 commit comments

Comments
 (0)