using SuiteLink.Client; namespace SuiteLink.Client.Tests; public sealed class SuiteLinkConnectionOptionsTests { public static TheoryData InvalidRequiredValues => new() { null, "", " ", "\t" }; [Theory] [MemberData(nameof(InvalidRequiredValues))] public void Constructor_InvalidHost_ThrowsArgumentException(string? host) { Assert.Throws(() => Create(host: host!)); } [Theory] [MemberData(nameof(InvalidRequiredValues))] public void Constructor_InvalidApplication_ThrowsArgumentException(string? application) { Assert.Throws(() => Create(application: application!)); } [Theory] [MemberData(nameof(InvalidRequiredValues))] public void Constructor_InvalidTopic_ThrowsArgumentException(string? topic) { Assert.Throws(() => Create(topic: topic!)); } [Theory] [MemberData(nameof(InvalidRequiredValues))] public void Constructor_InvalidClientName_ThrowsArgumentException(string? clientName) { Assert.Throws(() => Create(clientName: clientName!)); } [Theory] [MemberData(nameof(InvalidRequiredValues))] public void Constructor_InvalidClientNode_ThrowsArgumentException(string? clientNode) { Assert.Throws(() => Create(clientNode: clientNode!)); } [Theory] [MemberData(nameof(InvalidRequiredValues))] public void Constructor_InvalidUserName_ThrowsArgumentException(string? userName) { Assert.Throws(() => Create(userName: userName!)); } [Theory] [MemberData(nameof(InvalidRequiredValues))] public void Constructor_InvalidServerNode_ThrowsArgumentException(string? serverNode) { Assert.Throws(() => Create(serverNode: serverNode!)); } [Theory] [InlineData(0)] [InlineData(-1)] [InlineData(65536)] public void Constructor_InvalidPort_ThrowsArgumentOutOfRangeException(int port) { Assert.Throws(() => Create(port: port)); } [Fact] public void Constructor_NoTimezone_UsesUtcByDefault() { var options = Create(timezone: null); Assert.Equal("UTC", options.Timezone); } [Theory] [InlineData("")] [InlineData(" ")] [InlineData("\t")] public void Constructor_WhitespaceTimezone_UsesUtcByDefault(string timezone) { var options = Create(timezone: timezone); Assert.Equal("UTC", options.Timezone); } [Fact] public void Constructor_ExplicitTimezone_PreservesProvidedValue() { var options = Create(timezone: "America/Indiana/Indianapolis"); Assert.Equal("America/Indiana/Indianapolis", options.Timezone); } private static SuiteLinkConnectionOptions Create( string host = "127.0.0.1", string application = "TestApp", string topic = "TestTopic", string clientName = "Client", string clientNode = "Node", string userName = "User", string serverNode = "Server", string? timezone = null, int port = 5413) { return new SuiteLinkConnectionOptions( host, application, topic, clientName, clientNode, userName, serverNode, timezone, port); } }