diff --git a/DigitalData.Auth.Tests/Client/AuthClientTests.cs b/DigitalData.Auth.Tests/Client/AuthClientTests.cs index 644825d..63aac1f 100644 --- a/DigitalData.Auth.Tests/Client/AuthClientTests.cs +++ b/DigitalData.Auth.Tests/Client/AuthClientTests.cs @@ -4,7 +4,6 @@ using DigitalData.Auth.Client; using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; -using System.Reflection; namespace DigitalData.Auth.Tests.Client; @@ -15,9 +14,7 @@ public class AuthClientTests private Func, ServiceProvider> Build; - private readonly WebApplication? _app = null; - - private readonly Queue _clientPool = new(); + private WebApplication? _app = null; private static int AvailablePort { @@ -38,19 +35,7 @@ public class AuthClientTests .AddAuthHubClient(options) .BuildServiceProvider(); - var testCount = GetType().GetMethods(BindingFlags.Public | BindingFlags.Instance) - .Where(m => m.GetCustomAttributes(typeof(TestAttribute), false).Length != 0 || - m.GetCustomAttributes(typeof(TestCaseAttribute), false).Any()) - .Count(); - - for(int i = 0; i < testCount; i++) - { - using var provider = Build(opt => opt.Url = _hubUrl); - var client = provider.GetRequiredService(); - _clientPool.Append(client); - } - - /* Create and run test server */ + // Create and run test server // Create builder and add SignalR service var builder = WebApplication.CreateBuilder(); builder.Services.AddSignalR(); @@ -81,7 +66,8 @@ public class AuthClientTests public async Task StartAsync_ShouldConnectSuccessfully() { // Arrange - var client = _clientPool.Dequeue(); + using var provider = Build(opt => opt.Url = _hubUrl); + var client = provider.GetRequiredService(); // Act await client.TryStartAsync(); @@ -101,7 +87,11 @@ public class AuthClientTests // Arrange string rcv_user = string.Empty; string rcv_msg = string.Empty; - var sender_client = _clientPool.Dequeue(); + + // Sender client + using var provider_sender = Build(opt => opt.Url = _hubUrl); + var sender_client = provider_sender.GetRequiredService(); + await sender_client.TryStartAsync(); // Receiver client using var provider_receiver = Build(opt =>