tests: fix up test project after major refactor
This commit is contained in:
@@ -2,9 +2,7 @@ using WebSocket = System.Net.WebSockets.WebSocket;
|
||||
|
||||
namespace StevesBot.Worker.Tests.Integration.Infrastructure;
|
||||
|
||||
# pragma warning disable CA1001
|
||||
|
||||
public sealed class TestWebSocketServer : IAsyncLifetime
|
||||
public sealed class TestWebSocketServer : IAsyncLifetime, IDisposable
|
||||
{
|
||||
private readonly IWebHost _host;
|
||||
private readonly CancellationTokenSource _echoCts = new();
|
||||
@@ -111,4 +109,9 @@ public sealed class TestWebSocketServer : IAsyncLifetime
|
||||
webSocket.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_host.Dispose();
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ public sealed class DiscordGatewayClientTests : IDisposable
|
||||
private readonly Mock<IWebSocketFactory> _mockWebSocketFactory = new();
|
||||
private readonly Mock<ILogger<DiscordGatewayClient>> _mockLogger = new();
|
||||
private readonly Mock<TimeProvider> _mockTimeProvider = new();
|
||||
private readonly Mock<IServiceScopeFactory> _mockServiceScopeFactory = new();
|
||||
private readonly DiscordClientOptions _options = new();
|
||||
private readonly DiscordGatewayClient _discordGatewayClient;
|
||||
|
||||
@@ -20,7 +21,8 @@ public sealed class DiscordGatewayClientTests : IDisposable
|
||||
_mockWebSocketFactory.Object,
|
||||
_mockLogger.Object,
|
||||
_mockDiscordRestClient.Object,
|
||||
_mockTimeProvider.Object
|
||||
_mockTimeProvider.Object,
|
||||
_mockServiceScopeFactory.Object
|
||||
);
|
||||
}
|
||||
|
||||
@@ -32,7 +34,8 @@ public sealed class DiscordGatewayClientTests : IDisposable
|
||||
_mockWebSocketFactory.Object,
|
||||
_mockLogger.Object,
|
||||
_mockDiscordRestClient.Object,
|
||||
_mockTimeProvider.Object
|
||||
_mockTimeProvider.Object,
|
||||
_mockServiceScopeFactory.Object
|
||||
);
|
||||
|
||||
act.Should().Throw<ArgumentNullException>();
|
||||
@@ -46,7 +49,8 @@ public sealed class DiscordGatewayClientTests : IDisposable
|
||||
null!,
|
||||
_mockLogger.Object,
|
||||
_mockDiscordRestClient.Object,
|
||||
_mockTimeProvider.Object
|
||||
_mockTimeProvider.Object,
|
||||
_mockServiceScopeFactory.Object
|
||||
);
|
||||
|
||||
act.Should().Throw<ArgumentNullException>();
|
||||
@@ -60,7 +64,8 @@ public sealed class DiscordGatewayClientTests : IDisposable
|
||||
_mockWebSocketFactory.Object,
|
||||
null!,
|
||||
_mockDiscordRestClient.Object,
|
||||
_mockTimeProvider.Object
|
||||
_mockTimeProvider.Object,
|
||||
_mockServiceScopeFactory.Object
|
||||
);
|
||||
|
||||
act.Should().Throw<ArgumentNullException>();
|
||||
@@ -74,7 +79,8 @@ public sealed class DiscordGatewayClientTests : IDisposable
|
||||
_mockWebSocketFactory.Object,
|
||||
_mockLogger.Object,
|
||||
null!,
|
||||
_mockTimeProvider.Object
|
||||
_mockTimeProvider.Object,
|
||||
_mockServiceScopeFactory.Object
|
||||
);
|
||||
|
||||
act.Should().Throw<ArgumentNullException>();
|
||||
@@ -88,6 +94,22 @@ public sealed class DiscordGatewayClientTests : IDisposable
|
||||
_mockWebSocketFactory.Object,
|
||||
_mockLogger.Object,
|
||||
_mockDiscordRestClient.Object,
|
||||
null!,
|
||||
_mockServiceScopeFactory.Object
|
||||
);
|
||||
|
||||
act.Should().Throw<ArgumentNullException>();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_WhenCalledAndServiceScopeFactoryIsNull_ItShouldThrowArgumentNullException()
|
||||
{
|
||||
var act = () => new DiscordGatewayClient(
|
||||
_options,
|
||||
_mockWebSocketFactory.Object,
|
||||
_mockLogger.Object,
|
||||
_mockDiscordRestClient.Object,
|
||||
_mockTimeProvider.Object,
|
||||
null!
|
||||
);
|
||||
|
||||
|
||||
@@ -16,8 +16,10 @@ global using Moq;
|
||||
|
||||
global using RichardSzalay.MockHttp;
|
||||
|
||||
global using StevesBot.Worker.Discord;
|
||||
global using StevesBot.Worker.Discord.Events;
|
||||
global using StevesBot.Worker.Discord.Gateway;
|
||||
global using StevesBot.Worker.Discord.Gateway.Events;
|
||||
global using StevesBot.Worker.Discord.Rest;
|
||||
global using StevesBot.Worker.Discord.Shared;
|
||||
global using StevesBot.Worker.Tests.Integration.Infrastructure;
|
||||
global using StevesBot.Worker.Threading;
|
||||
global using StevesBot.Worker.WebSockets;
|
||||
Reference in New Issue
Block a user