Revert "feat(AuthClientTests): Es wurde eine clientPool-Warteschlange erstellt, um die Injektion von Abhängigkeiten und die Bereitstellung von Diensten zu trennen."
This reverts commit 5886e076f4698fae293f56fad238c1563b2a10e3.
This commit is contained in:
parent
7c5a545926
commit
360d91353b
@ -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<Action<ClientParams>, ServiceProvider> Build;
|
||||
|
||||
private readonly WebApplication? _app = null;
|
||||
|
||||
private readonly Queue<IAuthClient> _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<IAuthClient>();
|
||||
_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<IAuthClient>();
|
||||
|
||||
// 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<IAuthClient>();
|
||||
await sender_client.TryStartAsync();
|
||||
|
||||
// Receiver client
|
||||
using var provider_receiver = Build(opt =>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user