using System.Net; namespace AcDream.Core.Net.Tests; public sealed class WorldSessionConstructionTests { [Fact] public void InvalidEndpointIsRejectedBeforeTransportAllocation() { int allocationCount = 0; IWorldSessionTransport Allocate(IPEndPoint _) { allocationCount++; return new TestTransport(); } Assert.Throws( () => new WorldSession(null!, Allocate)); Assert.Throws( () => new WorldSession( new IPEndPoint(IPAddress.Loopback, ushort.MaxValue), Allocate)); Assert.Equal(0, allocationCount); } private sealed class TestTransport : IWorldSessionTransport { public void Send(ReadOnlySpan datagram) { } public void Send(IPEndPoint remote, ReadOnlySpan datagram) { } public byte[]? Receive(TimeSpan timeout, out IPEndPoint? from) { from = null; return null; } public void Dispose() { } } }