using XFEExtension.NetCore.AutoConfig; using XFEExtension.NetCore.CyberComm; using XFEExtension.NetCore.ServerInteractive.TServer.Profiles; using Xunit; namespace XFEExtension.NetCore.ServerInteractive.Test; public sealed class ServerProfileTests { [Fact] public void ServerProfileRoundTripsThroughAutoConfig() { var directory = Path.Combine(Path.GetTempPath(), "XFEServerProfileTests", Guid.NewGuid().ToString("N")); var originalPath = ServerProfile.ProfilePath; var originalExtension = ServerProfile.ProfileExtension; var originalCurrent = ServerProfile.Current; try { ServerProfile.ProfilePath = Path.Combine(directory, nameof(ServerProfile)); ServerProfile.ProfileExtension = string.Empty; ServerProfile.Current = new ServerProfile(); ServerProfile.ListenUrls = new ProfileList(["http://127.0.0.1:4301/"]); ServerProfile.ShutdownTimeoutSeconds = 23; ServerProfile.TransportLimits = new CyberCommLimitOptions { MaxConnections = 321, MaxConnectionsPerIp = 21, CloseTimeout = TimeSpan.FromSeconds(7) }; ServerProfile.SaveProfile(); Assert.True(File.Exists(Path.Combine(directory, $"{nameof(ServerProfile)}.xpf"))); ServerProfile.Current = new ServerProfile(); ServerProfile.LoadProfile(); Assert.Equal(["http://127.0.0.1:4301/"], ServerProfile.ListenUrls); Assert.Equal(23, ServerProfile.ShutdownTimeoutSeconds); Assert.Equal(321, ServerProfile.TransportLimits.MaxConnections); Assert.Equal(21, ServerProfile.TransportLimits.MaxConnectionsPerIp); Assert.Equal(TimeSpan.FromSeconds(7), ServerProfile.CreateTransportLimits().CloseTimeout); } finally { ServerProfile.ProfilePath = originalPath; ServerProfile.ProfileExtension = originalExtension; ServerProfile.Current = originalCurrent; if (Directory.Exists(directory)) Directory.Delete(directory, true); } } }