build: bootstrap solution and quality gates (#3)
quality-gate / quality (push) Successful in 58s
quality-gate / quality (push) Successful in 58s
Closes #3
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
using System.Net;
|
||||
using FinalFactory.Rendezvous.Server.Transport;
|
||||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace FinalFactory.Rendezvous.Tests.Server;
|
||||
|
||||
public sealed class UdpMediatorServiceTests
|
||||
{
|
||||
[Fact]
|
||||
public async Task ServiceBindsAnEphemeralUdpPortAndStopsCleanly()
|
||||
{
|
||||
using CancellationTokenSource timeout = new(TimeSpan.FromSeconds(5));
|
||||
UdpMediatorOptions options = new()
|
||||
{
|
||||
ListenAddress = IPAddress.Loopback.ToString(),
|
||||
Port = 0,
|
||||
};
|
||||
using UdpMediatorService service = new(
|
||||
Options.Create(options),
|
||||
NullLogger<UdpMediatorService>.Instance);
|
||||
|
||||
await service.StartAsync(timeout.Token);
|
||||
|
||||
IPEndPoint? boundEndpoint = service.LocalEndpoint;
|
||||
Assert.NotNull(boundEndpoint);
|
||||
Assert.Equal(IPAddress.Loopback, boundEndpoint.Address);
|
||||
Assert.InRange(boundEndpoint.Port, 1, 65_535);
|
||||
|
||||
await service.StopAsync(timeout.Token);
|
||||
|
||||
Assert.Null(service.LocalEndpoint);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user