Reformat/cleanup
All checks were successful
NuGet Package Publish / nuget (push) Successful in 1m10s

This commit is contained in:
Joseph Doherty
2026-02-21 07:53:53 -05:00
parent c6f6d9329a
commit 7ebc2cb567
160 changed files with 7258 additions and 7262 deletions

View File

@@ -1,17 +1,16 @@
using System.IO;
using System.Net.Sockets;
using Microsoft.Extensions.Logging.Abstractions;
using ZB.MOM.WW.CBDDC.Core;
using ZB.MOM.WW.CBDDC.Core.Network;
using ZB.MOM.WW.CBDDC.Core.Storage;
using ZB.MOM.WW.CBDDC.Network.Security;
using Microsoft.Extensions.Logging.Abstractions;
namespace ZB.MOM.WW.CBDDC.Network.Tests;
public class ConnectionTests
{
/// <summary>
/// Verifies that the server rejects new clients when the configured connection limit is reached.
/// Verifies that the server rejects new clients when the configured connection limit is reached.
/// </summary>
[Fact]
public async Task Server_Should_Reject_Clients_When_Limit_Reached()
@@ -22,9 +21,11 @@ public class ConnectionTests
.Returns(new HlcTimestamp(0, 0, "node"));
oplogStore.GetVectorClockAsync(Arg.Any<CancellationToken>())
.Returns(new VectorClock());
oplogStore.GetOplogAfterAsync(Arg.Any<HlcTimestamp>(), Arg.Any<IEnumerable<string>?>(), Arg.Any<CancellationToken>())
oplogStore.GetOplogAfterAsync(Arg.Any<HlcTimestamp>(), Arg.Any<IEnumerable<string>?>(),
Arg.Any<CancellationToken>())
.Returns(Array.Empty<OplogEntry>());
oplogStore.GetOplogForNodeAfterAsync(Arg.Any<string>(), Arg.Any<HlcTimestamp>(), Arg.Any<IEnumerable<string>?>(), Arg.Any<CancellationToken>())
oplogStore.GetOplogForNodeAfterAsync(Arg.Any<string>(), Arg.Any<HlcTimestamp>(),
Arg.Any<IEnumerable<string>?>(), Arg.Any<CancellationToken>())
.Returns(Array.Empty<OplogEntry>());
var configProvider = Substitute.For<IPeerNodeConfigurationProvider>();
@@ -44,7 +45,8 @@ public class ConnectionTests
authenticator.ValidateAsync(Arg.Any<string>(), Arg.Any<string>()).Returns(true);
var handshakeService = Substitute.For<IPeerHandshakeService>();
handshakeService.HandshakeAsync(Arg.Any<Stream>(), Arg.Any<bool>(), Arg.Any<string>(), Arg.Any<CancellationToken>())
handshakeService.HandshakeAsync(Arg.Any<Stream>(), Arg.Any<bool>(), Arg.Any<string>(),
Arg.Any<CancellationToken>())
.Returns((CipherState?)null);
var server = new TcpSyncServer(
@@ -59,7 +61,7 @@ public class ConnectionTests
server.MaxConnections = 2;
await server.Start();
var port = server.ListeningPort ?? throw new Exception("Server not started");
int port = server.ListeningPort ?? throw new Exception("Server not started");
using var client1 = new TcpClient();
using var client2 = new TcpClient();
@@ -76,7 +78,7 @@ public class ConnectionTests
// Assert
var stream3 = client3.GetStream();
var buffer = new byte[10];
var read = await stream3.ReadAsync(buffer, 0, 10);
int read = await stream3.ReadAsync(buffer, 0, 10);
read.ShouldBe(0, "Server should close connection immediately for client 3");
client1.Connected.ShouldBeTrue();
@@ -87,4 +89,4 @@ public class ConnectionTests
await server.Stop();
}
}
}
}