Use CollectionFixture instead of ClassFixture
MODIFY
MagicalCryptoWallet.Tests/ClientSideFilter/PersistenceTest.cs
MagicalCryptoWallet.Tests/ClientSideFilter/PersistenceTest.cs
@@ -11,7 +11,8 @@ using Xunit;
namespace MagicalCryptoWallet.Tests
{
- public class PersistenceTest : IClassFixture<SharedFixture>
+ [Collection("Shared collection")]
+ public class PersistenceTest
{
private SharedFixture SharedFixture { get; }

MODIFY
MagicalCryptoWallet.Tests/ClientSideFilter/StoreTest.cs
MagicalCryptoWallet.Tests/ClientSideFilter/StoreTest.cs
@@ -8,7 +8,8 @@ using Xunit;
namespace MagicalCryptoWallet.Tests
{
- public class StoreTest : IClassFixture<SharedFixture>
+ [Collection("Shared collection")]
+ public class StoreTest
{
private SharedFixture SharedFixture { get; }

MODIFY
MagicalCryptoWallet.Tests/CryptoTests.cs
MagicalCryptoWallet.Tests/CryptoTests.cs
@@ -8,7 +8,8 @@ using Xunit;
namespace MagicalCryptoWallet.Tests
{
- public class CryptoTests : IClassFixture<SharedFixture>
+ [Collection("Shared collection")]
+ public class CryptoTests
{
private SharedFixture SharedFixture { get; }

MODIFY
MagicalCryptoWallet.Tests/KeyManagementTests.cs
MagicalCryptoWallet.Tests/KeyManagementTests.cs
@@ -9,7 +9,8 @@ using Xunit;
namespace MagicalCryptoWallet.Tests
{
- public class KeyManagementTests : IClassFixture<SharedFixture>
+ [Collection("Shared collection")]
+ public class KeyManagementTests
{
private SharedFixture SharedFixture { get; }

MODIFY
MagicalCryptoWallet.Tests/P2pTests.cs
MagicalCryptoWallet.Tests/P2pTests.cs
@@ -19,7 +19,8 @@ using Xunit;
namespace MagicalCryptoWallet.Tests
{
- public class P2pTests : IClassFixture<SharedFixture>
+ [Collection("Shared collection")]
+ public class P2pTests
{
private SharedFixture SharedFixture { get; }

MODIFY
MagicalCryptoWallet.Tests/RegTests.cs
MagicalCryptoWallet.Tests/RegTests.cs
@@ -26,37 +26,14 @@ using Xunit;
namespace MagicalCryptoWallet.Tests
{
- public class RegTests : IClassFixture<SharedFixture>
+ [Collection("Shared collection")]
+ public class RegTests
{
private SharedFixture Fixture { get; }
public RegTests(SharedFixture fixture)
{
Fixture = fixture;
-
- if (Fixture.BackendNodeBuilder == null)
- {
- Fixture.BackendNodeBuilder = NodeBuilder.CreateAsync().GetAwaiter().GetResult();
- Fixture.BackendNodeBuilder.CreateNodeAsync().GetAwaiter().GetResult();;
- Fixture.BackendNodeBuilder.StartAllAsync().GetAwaiter().GetResult();;
- Fixture.BackendRegTestNode = Fixture.BackendNodeBuilder.Nodes[0];
- Fixture.BackendRegTestNode.Generate(101);
- var rpc = Fixture.BackendRegTestNode.CreateRpcClient();
-
- var authString = rpc.Authentication.Split(':');
- Global.InitializeAsync(rpc.Network, authString[0], authString[1], rpc).GetAwaiter().GetResult();
-
- Fixture.BackendEndPoint = $"http://localhost:{new Random().Next(37130, 38000)}/";
- Fixture.BackendHost = WebHost.CreateDefaultBuilder()
- .UseStartup<Startup>()
- .UseUrls(Fixture.BackendEndPoint)
- .Build();
- var hostInitializationTask = Fixture.BackendHost.RunAsync();
- Logger.LogInfo<SharedFixture>($"Started Backend webhost: {Fixture.BackendEndPoint}");
-
- var delayTask = Task.Delay(3000);
- Task.WaitAny(delayTask, hostInitializationTask); // Wait for server to initialize (Without this OSX CI will fail)
- }
}
private async Task AssertFiltersInitializedAsync()

MODIFY
MagicalCryptoWallet.Tests/RpcMethodTests.cs
MagicalCryptoWallet.Tests/RpcMethodTests.cs
@@ -6,7 +6,8 @@ using Xunit;
namespace MagicalCryptoWallet.Tests
{
- public class RpcMethodTests : IClassFixture<SharedFixture>
+ [Collection("Shared collection")]
+ public class RpcMethodTests
{
private SharedFixture SharedFixture { get; }

MODIFY
MagicalCryptoWallet.Tests/SharedFixture.cs
MagicalCryptoWallet.Tests/SharedFixture.cs
@@ -8,6 +8,7 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
+using System.Threading.Tasks;
namespace MagicalCryptoWallet.Tests
{
@@ -38,14 +39,31 @@ namespace MagicalCryptoWallet.Tests
{
// Initialize tests...
- BackendEndPoint = null;
- BackendHost = null;
- BackendNodeBuilder = null;
- BackendRegTestNode = null;
-
Logger.SetFilePath(Path.Combine(DataDir, "Logs.txt"));
Logger.SetMinimumLevel(LogLevel.Info);
Logger.SetModes(LogMode.Debug, LogMode.Console, LogMode.File);
+
+ BackendNodeBuilder = NodeBuilder.CreateAsync().GetAwaiter().GetResult();
+ BackendNodeBuilder.CreateNodeAsync().GetAwaiter().GetResult();
+ BackendNodeBuilder.StartAllAsync().GetAwaiter().GetResult();
+ BackendRegTestNode = BackendNodeBuilder.Nodes[0];
+
+ var rpc = BackendRegTestNode.CreateRpcClient();
+
+ var authString = rpc.Authentication.Split(':');
+ Global.InitializeAsync(rpc.Network, authString[0], authString[1], rpc).GetAwaiter().GetResult();
+
+ BackendEndPoint = $"http://localhost:{new Random().Next(37130, 38000)}/";
+ BackendHost = WebHost.CreateDefaultBuilder()
+ .UseStartup<Startup>()
+ .UseUrls(BackendEndPoint)
+ .Build();
+
+ var hostInitializationTask = BackendHost.RunAsync();
+ Logger.LogInfo<SharedFixture>($"Started Backend webhost: {BackendEndPoint}");
+
+ var delayTask = Task.Delay(3000);
+ Task.WaitAny(delayTask, hostInitializationTask); // Wait for server to initialize (Without this OSX CI will fail)
}
public void Dispose()

MODIFY
MagicalCryptoWallet.Tests/SmartModelTests.cs
MagicalCryptoWallet.Tests/SmartModelTests.cs
@@ -10,7 +10,8 @@ using Xunit;
namespace MagicalCryptoWallet.Tests
{
- public class SmartModelTests : IClassFixture<SharedFixture>
+ [Collection("Shared collection")]
+ public class SmartModelTests
{
private SharedFixture SharedFixture { get; }

MODIFY
MagicalCryptoWallet.Tests/TorTests.cs
MagicalCryptoWallet.Tests/TorTests.cs
@@ -11,7 +11,8 @@ using Xunit;
namespace MagicalCryptoWallet.Tests
{
// Tor must be running
- public class TorTests : IClassFixture<SharedFixture>
+ [Collection("Shared collection")]
+ public class TorTests
{
private SharedFixture SharedFixture { get; }

Use CollectionFixture instead of ClassFixture