From 46d680f20c6e014c0b710192ce03daec38c3e148 Mon Sep 17 00:00:00 2001 From: Gregorius Soedharmo Date: Wed, 22 Feb 2023 01:54:10 +0700 Subject: [PATCH] [TESTKIT] Reintroduce old code and mark them obsolete (#6420) * Reintroduce old code and mark them obsolete * Reintroduce IDisposable --------- Co-authored-by: Aaron Stannard --- .../testkits/Akka.TestKit.Xunit2/TestKit.cs | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/src/contrib/testkits/Akka.TestKit.Xunit2/TestKit.cs b/src/contrib/testkits/Akka.TestKit.Xunit2/TestKit.cs index 393f553df35..cdb70c8231e 100644 --- a/src/contrib/testkits/Akka.TestKit.Xunit2/TestKit.cs +++ b/src/contrib/testkits/Akka.TestKit.Xunit2/TestKit.cs @@ -21,7 +21,7 @@ namespace Akka.TestKit.Xunit2 /// This class represents an Akka.NET TestKit that uses xUnit /// as its testing framework. /// - public class TestKit : TestKitBase, IAsyncLifetime + public class TestKit : TestKitBase, IAsyncLifetime, IDisposable { private class PrefixedOutput : ITestOutputHelper { @@ -132,8 +132,19 @@ public TestKit(string config, ITestOutputHelper output = null) /// protected virtual async Task AfterAllAsync() { +#pragma warning disable CS0618 + AfterAll(); +#pragma warning restore CS0618 await ShutdownAsync(); } + + /// + /// This method is called when a test ends. + /// + [Obsolete("AfterAll() is deprecated, please use AfterAllAsync() instead")] + protected virtual void AfterAll() + { + } /// /// Initializes a new used to log messages. @@ -169,6 +180,29 @@ public virtual Task InitializeAsync() public virtual async Task DisposeAsync() { await AfterAllAsync(); +#pragma warning disable CS0618 + Dispose(); +#pragma warning restore CS0618 + } + + /// + /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. + /// + /// + /// if set to true the method has been called directly or indirectly by a user's code. + /// Managed and unmanaged resources will be disposed.
if set to false the method + /// has been called by the runtime from inside the finalizer and only unmanaged resources can + /// be disposed. + /// + [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); } } }