Skip to content

Commit

Permalink
Port Akka.Tests.Event tests to async/await - LoggerSpec (#5795)
Browse files Browse the repository at this point in the history
  • Loading branch information
eaba authored Mar 30, 2022
1 parent 7109814 commit ab5071d
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/core/Akka.Tests/Event/LoggerSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public LoggerSpec(ITestOutputHelper helper) : base(Config, helper) { }
[InlineData(LogLevel.DebugLevel, true, "foo", new object[] { })]
[InlineData(LogLevel.DebugLevel, false, "foo {0}", new object[] { 1 })]
[InlineData(LogLevel.DebugLevel, true, "foo {0}", new object[] { 1 })]
public void LoggingAdapter_should_log_all_information(LogLevel logLevel, bool includeException, string formatStr, object [] args)
public async Task LoggingAdapter_should_log_all_information(LogLevel logLevel, bool includeException, string formatStr, object [] args)
{
Sys.EventStream.Subscribe(TestActor, typeof(LogEvent));
var msg = args != null ? string.Format(formatStr, args) : formatStr;
Expand Down Expand Up @@ -102,10 +102,10 @@ void ProcessLog(LogEvent logEvent)
logEvent.Cause.Should().BeNull();
}

var log = ExpectMsg<LogEvent>();
var log = await ExpectMsgAsync<LogEvent>();
ProcessLog(log);

var log2 = ExpectMsg<LogEvent>();
var log2 = await ExpectMsgAsync<LogEvent>();
ProcessLog(log2);
}

Expand All @@ -117,23 +117,23 @@ public async Task LoggingBus_should_stop_all_loggers_on_termination()
system.EventStream.Subscribe(TestActor, typeof(Debug));
await system.Terminate();

await AwaitAssertAsync(() =>
await AwaitAssertAsync(async() =>
{
var shutdownInitiated = ExpectMsg<Debug>(TestKitSettings.DefaultTimeout);
var shutdownInitiated = await ExpectMsgAsync<Debug>(TestKitSettings.DefaultTimeout);
shutdownInitiated.Message.ShouldBe("System shutdown initiated");
});

var loggerStarted = ExpectMsg<Debug>(TestKitSettings.DefaultTimeout);
var loggerStarted = await ExpectMsgAsync<Debug>(TestKitSettings.DefaultTimeout);
loggerStarted.Message.ShouldBe("Shutting down: StandardOutLogger started");
loggerStarted.LogClass.ShouldBe(typeof(EventStream));
loggerStarted.LogSource.ShouldBe(typeof(EventStream).Name);

var loggerStopped = ExpectMsg<Debug>(TestKitSettings.DefaultTimeout);
var loggerStopped = await ExpectMsgAsync<Debug>(TestKitSettings.DefaultTimeout);
loggerStopped.Message.ShouldBe("All default loggers stopped");
loggerStopped.LogClass.ShouldBe(typeof(EventStream));
loggerStopped.LogSource.ShouldBe(typeof(EventStream).Name);

ExpectNoMsg(TimeSpan.FromSeconds(1));
await ExpectNoMsgAsync(TimeSpan.FromSeconds(1));
}
}
}
Expand Down

0 comments on commit ab5071d

Please sign in to comment.