Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port Akka.Tests.Event tests to async/await - LoggerSpec #5795

Merged
merged 2 commits into from
Mar 30, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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