Linter/formatter pass across the full codebase. Restores required partial keyword on AXAML code-behind classes that the formatter incorrectly removed. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
95 lines
2.9 KiB
C#
95 lines
2.9 KiB
C#
using Shouldly;
|
|
using Xunit;
|
|
using ZB.MOM.WW.LmxOpcUa.Client.Shared.Models;
|
|
|
|
namespace ZB.MOM.WW.LmxOpcUa.Client.Shared.Tests.Models;
|
|
|
|
public class ConnectionSettingsTests
|
|
{
|
|
[Fact]
|
|
public void Defaults_AreCorrect()
|
|
{
|
|
var settings = new ConnectionSettings();
|
|
|
|
settings.EndpointUrl.ShouldBe(string.Empty);
|
|
settings.FailoverUrls.ShouldBeNull();
|
|
settings.Username.ShouldBeNull();
|
|
settings.Password.ShouldBeNull();
|
|
settings.SecurityMode.ShouldBe(SecurityMode.None);
|
|
settings.SessionTimeoutSeconds.ShouldBe(60);
|
|
settings.AutoAcceptCertificates.ShouldBeTrue();
|
|
settings.CertificateStorePath.ShouldContain("LmxOpcUaClient");
|
|
settings.CertificateStorePath.ShouldContain("pki");
|
|
}
|
|
|
|
[Fact]
|
|
public void Validate_ThrowsOnNullEndpointUrl()
|
|
{
|
|
var settings = new ConnectionSettings { EndpointUrl = null! };
|
|
Should.Throw<ArgumentException>(() => settings.Validate())
|
|
.ParamName.ShouldBe("EndpointUrl");
|
|
}
|
|
|
|
[Fact]
|
|
public void Validate_ThrowsOnEmptyEndpointUrl()
|
|
{
|
|
var settings = new ConnectionSettings { EndpointUrl = "" };
|
|
Should.Throw<ArgumentException>(() => settings.Validate())
|
|
.ParamName.ShouldBe("EndpointUrl");
|
|
}
|
|
|
|
[Fact]
|
|
public void Validate_ThrowsOnWhitespaceEndpointUrl()
|
|
{
|
|
var settings = new ConnectionSettings { EndpointUrl = " " };
|
|
Should.Throw<ArgumentException>(() => settings.Validate())
|
|
.ParamName.ShouldBe("EndpointUrl");
|
|
}
|
|
|
|
[Fact]
|
|
public void Validate_ThrowsOnZeroTimeout()
|
|
{
|
|
var settings = new ConnectionSettings
|
|
{
|
|
EndpointUrl = "opc.tcp://localhost:4840",
|
|
SessionTimeoutSeconds = 0
|
|
};
|
|
Should.Throw<ArgumentException>(() => settings.Validate())
|
|
.ParamName.ShouldBe("SessionTimeoutSeconds");
|
|
}
|
|
|
|
[Fact]
|
|
public void Validate_ThrowsOnNegativeTimeout()
|
|
{
|
|
var settings = new ConnectionSettings
|
|
{
|
|
EndpointUrl = "opc.tcp://localhost:4840",
|
|
SessionTimeoutSeconds = -1
|
|
};
|
|
Should.Throw<ArgumentException>(() => settings.Validate())
|
|
.ParamName.ShouldBe("SessionTimeoutSeconds");
|
|
}
|
|
|
|
[Fact]
|
|
public void Validate_ThrowsOnTimeoutAbove3600()
|
|
{
|
|
var settings = new ConnectionSettings
|
|
{
|
|
EndpointUrl = "opc.tcp://localhost:4840",
|
|
SessionTimeoutSeconds = 3601
|
|
};
|
|
Should.Throw<ArgumentException>(() => settings.Validate())
|
|
.ParamName.ShouldBe("SessionTimeoutSeconds");
|
|
}
|
|
|
|
[Fact]
|
|
public void Validate_SucceedsWithValidSettings()
|
|
{
|
|
var settings = new ConnectionSettings
|
|
{
|
|
EndpointUrl = "opc.tcp://localhost:4840",
|
|
SessionTimeoutSeconds = 120
|
|
};
|
|
Should.NotThrow(() => settings.Validate());
|
|
}
|
|
} |