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

[TESTKIT] Reintroduce old code and mark them obsolete #6420

Merged
merged 4 commits into from
Feb 21, 2023
Merged
Changes from all commits
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
36 changes: 35 additions & 1 deletion src/contrib/testkits/Akka.TestKit.Xunit2/TestKit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace Akka.TestKit.Xunit2
/// This class represents an Akka.NET TestKit that uses <a href="https://xunit.github.io/">xUnit</a>
/// as its testing framework.
/// </summary>
public class TestKit : TestKitBase, IAsyncLifetime
public class TestKit : TestKitBase, IAsyncLifetime, IDisposable
{
private class PrefixedOutput : ITestOutputHelper
{
Expand Down Expand Up @@ -132,8 +132,19 @@ public TestKit(string config, ITestOutputHelper output = null)
/// </summary>
protected virtual async Task AfterAllAsync()
{
#pragma warning disable CS0618
AfterAll();
#pragma warning restore CS0618
await ShutdownAsync();
}

/// <summary>
/// This method is called when a test ends.
/// </summary>
[Obsolete("AfterAll() is deprecated, please use AfterAllAsync() instead")]
protected virtual void AfterAll()
{
}

/// <summary>
/// Initializes a new <see cref="TestOutputLogger"/> used to log messages.
Expand Down Expand Up @@ -169,6 +180,29 @@ public virtual Task InitializeAsync()
public virtual async Task DisposeAsync()
{
await AfterAllAsync();
#pragma warning disable CS0618
Dispose();
#pragma warning restore CS0618
}

/// <summary>
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
/// </summary>
/// <param name="disposing">
/// if set to <c>true</c> the method has been called directly or indirectly by a user's code.
/// Managed and unmanaged resources will be disposed.<br /> if set to <c>false</c> the method
/// has been called by the runtime from inside the finalizer and only unmanaged resources can
/// be disposed.
/// </param>
[Obsolete("Dispose(bool) is deprecated, please use DisposeAsync() instead")]
protected virtual void Dispose(bool disposing)
Aaronontheweb marked this conversation as resolved.
Show resolved Hide resolved
{
}

[Obsolete("Dispose() is obsolete, please use DisposeAsync() instead")]
public void Dispose()
{
Dispose(true);
}
}
}