Skip to content

Commit

Permalink
[TESTKIT] Reintroduce old code and mark them obsolete (#6420)
Browse files Browse the repository at this point in the history
* Reintroduce old code and mark them obsolete

* Reintroduce IDisposable

---------

Co-authored-by: Aaron Stannard <aaron@petabridge.com>
  • Loading branch information
Arkatufus and Aaronontheweb committed Feb 21, 2023
1 parent b570276 commit 46d680f
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion src/contrib/testkits/Akka.TestKit.Xunit2/TestKit.cs
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)
{
}

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

0 comments on commit 46d680f

Please sign in to comment.