feat: bootstrap suitelink tag client codecs
This commit is contained in:
123
tests/SuiteLink.Client.Tests/SuiteLinkConnectionOptionsTests.cs
Normal file
123
tests/SuiteLink.Client.Tests/SuiteLinkConnectionOptionsTests.cs
Normal file
@@ -0,0 +1,123 @@
|
||||
using SuiteLink.Client;
|
||||
|
||||
namespace SuiteLink.Client.Tests;
|
||||
|
||||
public sealed class SuiteLinkConnectionOptionsTests
|
||||
{
|
||||
public static TheoryData<string?> InvalidRequiredValues =>
|
||||
new()
|
||||
{
|
||||
null,
|
||||
"",
|
||||
" ",
|
||||
"\t"
|
||||
};
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(InvalidRequiredValues))]
|
||||
public void Constructor_InvalidHost_ThrowsArgumentException(string? host)
|
||||
{
|
||||
Assert.Throws<ArgumentException>(() => Create(host: host!));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(InvalidRequiredValues))]
|
||||
public void Constructor_InvalidApplication_ThrowsArgumentException(string? application)
|
||||
{
|
||||
Assert.Throws<ArgumentException>(() => Create(application: application!));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(InvalidRequiredValues))]
|
||||
public void Constructor_InvalidTopic_ThrowsArgumentException(string? topic)
|
||||
{
|
||||
Assert.Throws<ArgumentException>(() => Create(topic: topic!));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(InvalidRequiredValues))]
|
||||
public void Constructor_InvalidClientName_ThrowsArgumentException(string? clientName)
|
||||
{
|
||||
Assert.Throws<ArgumentException>(() => Create(clientName: clientName!));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(InvalidRequiredValues))]
|
||||
public void Constructor_InvalidClientNode_ThrowsArgumentException(string? clientNode)
|
||||
{
|
||||
Assert.Throws<ArgumentException>(() => Create(clientNode: clientNode!));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(InvalidRequiredValues))]
|
||||
public void Constructor_InvalidUserName_ThrowsArgumentException(string? userName)
|
||||
{
|
||||
Assert.Throws<ArgumentException>(() => Create(userName: userName!));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(InvalidRequiredValues))]
|
||||
public void Constructor_InvalidServerNode_ThrowsArgumentException(string? serverNode)
|
||||
{
|
||||
Assert.Throws<ArgumentException>(() => Create(serverNode: serverNode!));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(0)]
|
||||
[InlineData(-1)]
|
||||
[InlineData(65536)]
|
||||
public void Constructor_InvalidPort_ThrowsArgumentOutOfRangeException(int port)
|
||||
{
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user