docs: backfill XML documentation across 756 files
v2-ci / build (push) Failing after 1m43s
v2-ci / unit-tests (tests/Core/ZB.MOM.WW.OtOpcUa.Cluster.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.ControlPlane.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.Runtime.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.Security.Tests) (push) Has been skipped
v2-ci / integration (tests/Server/ZB.MOM.WW.OtOpcUa.Host.IntegrationTests) (push) Has been skipped
v2-ci / integration (tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.IntegrationTests) (push) Has been skipped
v2-ci / build (push) Failing after 1m43s
v2-ci / unit-tests (tests/Core/ZB.MOM.WW.OtOpcUa.Cluster.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.ControlPlane.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.Runtime.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.Security.Tests) (push) Has been skipped
v2-ci / integration (tests/Server/ZB.MOM.WW.OtOpcUa.Host.IntegrationTests) (push) Has been skipped
v2-ci / integration (tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.IntegrationTests) (push) Has been skipped
Adds <summary>, <param>, <typeparam>, and <inheritdoc/> tags to public members surfaced by commentchecker — resolves 5,847 of 5,869 issues (99.6%) across three /fixdocs passes.
This commit is contained in:
@@ -7,6 +7,7 @@ namespace ZB.MOM.WW.OtOpcUa.Client.Shared.Tests;
|
||||
[Trait("Category", "Unit")]
|
||||
public sealed class ClientStoragePathsTests
|
||||
{
|
||||
/// <summary>Verifies that GetRoot returns the canonical folder name under LocalAppData.</summary>
|
||||
[Fact]
|
||||
public void GetRoot_ReturnsCanonicalFolderName_UnderLocalAppData()
|
||||
{
|
||||
@@ -15,6 +16,7 @@ public sealed class ClientStoragePathsTests
|
||||
root.ShouldContain(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData));
|
||||
}
|
||||
|
||||
/// <summary>Verifies that GetPkiPath nests PKI under root.</summary>
|
||||
[Fact]
|
||||
public void GetPkiPath_NestsPkiUnderRoot()
|
||||
{
|
||||
@@ -22,12 +24,14 @@ public sealed class ClientStoragePathsTests
|
||||
pki.ShouldEndWith(Path.Combine(ClientStoragePaths.CanonicalFolderName, "pki"));
|
||||
}
|
||||
|
||||
/// <summary>Verifies that CanonicalFolderName is OtOpcUaClient.</summary>
|
||||
[Fact]
|
||||
public void CanonicalFolderName_IsOtOpcUaClient()
|
||||
{
|
||||
ClientStoragePaths.CanonicalFolderName.ShouldBe("OtOpcUaClient");
|
||||
}
|
||||
|
||||
/// <summary>Verifies that LegacyFolderName is LmxOpcUaClient.</summary>
|
||||
[Fact]
|
||||
public void LegacyFolderName_IsLmxOpcUaClient()
|
||||
{
|
||||
@@ -36,6 +40,7 @@ public sealed class ClientStoragePathsTests
|
||||
ClientStoragePaths.LegacyFolderName.ShouldBe("LmxOpcUaClient");
|
||||
}
|
||||
|
||||
/// <summary>Verifies that TryRunLegacyMigration returns false on repeat invocation.</summary>
|
||||
[Fact]
|
||||
public void TryRunLegacyMigration_Returns_False_On_Repeat_Invocation()
|
||||
{
|
||||
|
||||
+6
@@ -6,10 +6,16 @@ namespace ZB.MOM.WW.OtOpcUa.Client.Shared.Tests.Fakes;
|
||||
|
||||
internal sealed class FakeApplicationConfigurationFactory : IApplicationConfigurationFactory
|
||||
{
|
||||
/// <summary>Gets or sets a value indicating whether to throw when Create is called.</summary>
|
||||
public bool ThrowOnCreate { get; set; }
|
||||
|
||||
/// <summary>Gets the number of times CreateAsync has been called.</summary>
|
||||
public int CreateCallCount { get; private set; }
|
||||
|
||||
/// <summary>Gets the last connection settings passed to CreateAsync.</summary>
|
||||
public ConnectionSettings? LastSettings { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<ApplicationConfiguration> CreateAsync(ConnectionSettings settings, CancellationToken ct)
|
||||
{
|
||||
CreateCallCount++;
|
||||
|
||||
@@ -5,10 +5,18 @@ namespace ZB.MOM.WW.OtOpcUa.Client.Shared.Tests.Fakes;
|
||||
|
||||
internal sealed class FakeEndpointDiscovery : IEndpointDiscovery
|
||||
{
|
||||
/// <summary>Gets or sets a value indicating whether SelectEndpoint should throw an exception.</summary>
|
||||
public bool ThrowOnSelect { get; set; }
|
||||
/// <summary>Gets the number of times SelectEndpoint has been called.</summary>
|
||||
public int SelectCallCount { get; private set; }
|
||||
/// <summary>Gets the last endpoint URL passed to SelectEndpoint.</summary>
|
||||
public string? LastEndpointUrl { get; private set; }
|
||||
|
||||
/// <summary>Selects an endpoint for the given configuration and URL, optionally throwing an exception.</summary>
|
||||
/// <param name="config">The application configuration.</param>
|
||||
/// <param name="endpointUrl">The endpoint URL to select.</param>
|
||||
/// <param name="requestedMode">The requested security mode.</param>
|
||||
/// <returns>The selected endpoint description.</returns>
|
||||
public EndpointDescription SelectEndpoint(ApplicationConfiguration config, string endpointUrl,
|
||||
MessageSecurityMode requestedMode)
|
||||
{
|
||||
|
||||
@@ -20,31 +20,53 @@ internal sealed class FakeSessionAdapter : ISessionAdapter
|
||||
/// Gets a value indicating whether the fake session has been disposed.
|
||||
/// </summary>
|
||||
public bool Disposed { get; private set; }
|
||||
/// <summary>Gets the number of times ReadValueAsync has been called.</summary>
|
||||
public int ReadCount { get; private set; }
|
||||
/// <summary>Gets the number of times WriteValueAsync has been called.</summary>
|
||||
public int WriteCount { get; private set; }
|
||||
/// <summary>Gets the number of times BrowseAsync has been called.</summary>
|
||||
public int BrowseCount { get; private set; }
|
||||
/// <summary>Gets the number of times BrowseNextAsync has been called.</summary>
|
||||
public int BrowseNextCount { get; private set; }
|
||||
/// <summary>Gets the number of times HasChildrenAsync has been called.</summary>
|
||||
public int HasChildrenCount { get; private set; }
|
||||
/// <summary>Gets the number of times HistoryReadRawAsync has been called.</summary>
|
||||
public int HistoryReadRawCount { get; private set; }
|
||||
/// <summary>Gets the number of times HistoryReadAggregateAsync has been called.</summary>
|
||||
public int HistoryReadAggregateCount { get; private set; }
|
||||
|
||||
// Configurable responses
|
||||
/// <summary>Gets or sets the data value returned by read operations.</summary>
|
||||
public DataValue? ReadResponse { get; set; }
|
||||
/// <summary>Gets or sets a function to generate read responses dynamically based on the node ID.</summary>
|
||||
public Func<NodeId, DataValue>? ReadResponseFunc { get; set; }
|
||||
/// <summary>Gets or sets the status code returned by write operations.</summary>
|
||||
public StatusCode WriteResponse { get; set; } = StatusCodes.Good;
|
||||
/// <summary>Gets or sets a value indicating whether read operations should throw an exception.</summary>
|
||||
public bool ThrowOnRead { get; set; }
|
||||
/// <summary>Gets or sets a value indicating whether write operations should throw an exception.</summary>
|
||||
public bool ThrowOnWrite { get; set; }
|
||||
/// <summary>Gets or sets a value indicating whether browse operations should throw an exception.</summary>
|
||||
public bool ThrowOnBrowse { get; set; }
|
||||
|
||||
/// <summary>Gets or sets the browse references returned by browse operations.</summary>
|
||||
public ReferenceDescriptionCollection BrowseResponse { get; set; } = [];
|
||||
/// <summary>Gets or sets the continuation point for browse operations.</summary>
|
||||
public byte[]? BrowseContinuationPoint { get; set; }
|
||||
/// <summary>Gets or sets the browse references returned by browse-next operations.</summary>
|
||||
public ReferenceDescriptionCollection BrowseNextResponse { get; set; } = [];
|
||||
/// <summary>Gets or sets the continuation point for browse-next operations.</summary>
|
||||
public byte[]? BrowseNextContinuationPoint { get; set; }
|
||||
/// <summary>Gets or sets the result returned by has-children operations.</summary>
|
||||
public bool HasChildrenResponse { get; set; } = false;
|
||||
|
||||
/// <summary>Gets or sets the historical values returned by raw history-read operations.</summary>
|
||||
public List<DataValue> HistoryReadRawResponse { get; set; } = [];
|
||||
/// <summary>Gets or sets the historical values returned by aggregate history-read operations.</summary>
|
||||
public List<DataValue> HistoryReadAggregateResponse { get; set; } = [];
|
||||
/// <summary>Gets or sets a value indicating whether raw history-read operations should throw an exception.</summary>
|
||||
public bool ThrowOnHistoryReadRaw { get; set; }
|
||||
/// <summary>Gets or sets a value indicating whether aggregate history-read operations should throw an exception.</summary>
|
||||
public bool ThrowOnHistoryReadAggregate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -210,6 +232,7 @@ internal sealed class FakeSessionAdapter : ISessionAdapter
|
||||
/// <summary>
|
||||
/// Simulates a keep-alive event.
|
||||
/// </summary>
|
||||
/// <param name="isGood">Whether the keep-alive status is good.</param>
|
||||
public void SimulateKeepAlive(bool isGood)
|
||||
{
|
||||
_keepAliveCallback?.Invoke(isGood);
|
||||
|
||||
@@ -8,8 +8,11 @@ internal sealed class FakeSessionFactory : ISessionFactory
|
||||
private readonly List<FakeSessionAdapter> _createdSessions = [];
|
||||
private readonly Queue<FakeSessionAdapter> _sessions = new();
|
||||
|
||||
/// <summary>Gets the number of times CreateSessionAsync has been called.</summary>
|
||||
public int CreateCallCount { get; private set; }
|
||||
/// <summary>Gets or sets a value indicating whether CreateSessionAsync should throw.</summary>
|
||||
public bool ThrowOnCreate { get; set; }
|
||||
/// <summary>Gets the endpoint URL from the last CreateSessionAsync call.</summary>
|
||||
public string? LastEndpointUrl { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -18,8 +21,17 @@ internal sealed class FakeSessionFactory : ISessionFactory
|
||||
/// </summary>
|
||||
public TaskCompletionSource? CreateGate { get; set; }
|
||||
|
||||
/// <summary>Gets the list of sessions created via CreateSessionAsync.</summary>
|
||||
public IReadOnlyList<FakeSessionAdapter> CreatedSessions => _createdSessions;
|
||||
|
||||
/// <summary>Creates a session asynchronously (fake implementation).</summary>
|
||||
/// <param name="config">The application configuration.</param>
|
||||
/// <param name="endpoint">The endpoint description.</param>
|
||||
/// <param name="sessionName">The session name.</param>
|
||||
/// <param name="sessionTimeoutMs">The session timeout in milliseconds.</param>
|
||||
/// <param name="identity">The user identity.</param>
|
||||
/// <param name="ct">Cancellation token.</param>
|
||||
/// <returns>A task containing the session adapter.</returns>
|
||||
public async Task<ISessionAdapter> CreateSessionAsync(
|
||||
ApplicationConfiguration config, EndpointDescription endpoint, string sessionName,
|
||||
uint sessionTimeoutMs, UserIdentity identity, CancellationToken ct)
|
||||
@@ -54,6 +66,7 @@ internal sealed class FakeSessionFactory : ISessionFactory
|
||||
/// <summary>
|
||||
/// Enqueues a session adapter to be returned on the next call to CreateSessionAsync.
|
||||
/// </summary>
|
||||
/// <param name="session">The session adapter to enqueue.</param>
|
||||
public void EnqueueSession(FakeSessionAdapter session)
|
||||
{
|
||||
_sessions.Enqueue(session);
|
||||
|
||||
@@ -31,8 +31,13 @@ internal sealed class FakeSubscriptionAdapter : ISubscriptionAdapter
|
||||
/// Gets or sets a value indicating whether condition refresh should throw to simulate unsupported servers.
|
||||
/// </summary>
|
||||
public bool ThrowOnConditionRefresh { get; set; }
|
||||
/// <summary>Gets the number of times AddDataChangeMonitoredItemAsync was called.</summary>
|
||||
public int AddDataChangeCount { get; private set; }
|
||||
|
||||
/// <summary>Gets the number of times AddEventMonitoredItemAsync was called.</summary>
|
||||
public int AddEventCount { get; private set; }
|
||||
|
||||
/// <summary>Gets the number of times RemoveMonitoredItemAsync was called.</summary>
|
||||
public int RemoveCount { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -115,6 +120,8 @@ internal sealed class FakeSubscriptionAdapter : ISubscriptionAdapter
|
||||
/// <summary>
|
||||
/// Simulates a data change notification for testing.
|
||||
/// </summary>
|
||||
/// <param name="handle">The monitored item handle.</param>
|
||||
/// <param name="value">The new data value to simulate.</param>
|
||||
public void SimulateDataChange(uint handle, DataValue value)
|
||||
{
|
||||
(NodeId NodeId, Action<string, DataValue>? DataCallback, Action<EventFieldList>? EventCallback) item;
|
||||
@@ -129,6 +136,8 @@ internal sealed class FakeSubscriptionAdapter : ISubscriptionAdapter
|
||||
/// <summary>
|
||||
/// Simulates an event notification for testing.
|
||||
/// </summary>
|
||||
/// <param name="handle">The monitored item handle.</param>
|
||||
/// <param name="eventFields">The event field list to simulate.</param>
|
||||
public void SimulateEvent(uint handle, EventFieldList eventFields)
|
||||
{
|
||||
(NodeId NodeId, Action<string, DataValue>? DataCallback, Action<EventFieldList>? EventCallback) item;
|
||||
|
||||
+10
@@ -8,6 +8,8 @@ namespace ZB.MOM.WW.OtOpcUa.Client.Shared.Tests.Helpers;
|
||||
|
||||
public class AggregateTypeMapperTests
|
||||
{
|
||||
/// <summary>Verifies that ToNodeId returns a non-null NodeId for all AggregateType values.</summary>
|
||||
/// <param name="aggregate">The aggregate type to test.</param>
|
||||
[Theory]
|
||||
[InlineData(AggregateType.Average)]
|
||||
[InlineData(AggregateType.Minimum)]
|
||||
@@ -23,42 +25,49 @@ public class AggregateTypeMapperTests
|
||||
nodeId.IsNullNodeId.ShouldBeFalse();
|
||||
}
|
||||
|
||||
/// <summary>Verifies that Average aggregate type maps to the correct OPC UA node ID.</summary>
|
||||
[Fact]
|
||||
public void ToNodeId_Average_MapsCorrectly()
|
||||
{
|
||||
AggregateTypeMapper.ToNodeId(AggregateType.Average).ShouldBe(ObjectIds.AggregateFunction_Average);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that Minimum aggregate type maps to the correct OPC UA node ID.</summary>
|
||||
[Fact]
|
||||
public void ToNodeId_Minimum_MapsCorrectly()
|
||||
{
|
||||
AggregateTypeMapper.ToNodeId(AggregateType.Minimum).ShouldBe(ObjectIds.AggregateFunction_Minimum);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that Maximum aggregate type maps to the correct OPC UA node ID.</summary>
|
||||
[Fact]
|
||||
public void ToNodeId_Maximum_MapsCorrectly()
|
||||
{
|
||||
AggregateTypeMapper.ToNodeId(AggregateType.Maximum).ShouldBe(ObjectIds.AggregateFunction_Maximum);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that Count aggregate type maps to the correct OPC UA node ID.</summary>
|
||||
[Fact]
|
||||
public void ToNodeId_Count_MapsCorrectly()
|
||||
{
|
||||
AggregateTypeMapper.ToNodeId(AggregateType.Count).ShouldBe(ObjectIds.AggregateFunction_Count);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that Start aggregate type maps to the correct OPC UA node ID.</summary>
|
||||
[Fact]
|
||||
public void ToNodeId_Start_MapsCorrectly()
|
||||
{
|
||||
AggregateTypeMapper.ToNodeId(AggregateType.Start).ShouldBe(ObjectIds.AggregateFunction_Start);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that End aggregate type maps to the correct OPC UA node ID.</summary>
|
||||
[Fact]
|
||||
public void ToNodeId_End_MapsCorrectly()
|
||||
{
|
||||
AggregateTypeMapper.ToNodeId(AggregateType.End).ShouldBe(ObjectIds.AggregateFunction_End);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that StandardDeviation aggregate type maps to the correct OPC UA node ID.</summary>
|
||||
[Fact]
|
||||
public void ToNodeId_StandardDeviation_MapsCorrectly()
|
||||
{
|
||||
@@ -66,6 +75,7 @@ public class AggregateTypeMapperTests
|
||||
.ShouldBe(ObjectIds.AggregateFunction_StandardDeviationPopulation);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that invalid aggregate type value throws ArgumentOutOfRangeException.</summary>
|
||||
[Fact]
|
||||
public void ToNodeId_InvalidValue_Throws()
|
||||
{
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace ZB.MOM.WW.OtOpcUa.Client.Shared.Tests.Helpers;
|
||||
|
||||
public class FailoverUrlParserTests
|
||||
{
|
||||
/// <summary>Verifies that Parse returns only the primary URL when CSV failover list is null.</summary>
|
||||
[Fact]
|
||||
public void Parse_CsvNull_ReturnsPrimaryOnly()
|
||||
{
|
||||
@@ -13,6 +14,7 @@ public class FailoverUrlParserTests
|
||||
result.ShouldBe(["opc.tcp://primary:4840"]);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that Parse returns only the primary URL when CSV failover list is empty.</summary>
|
||||
[Fact]
|
||||
public void Parse_CsvEmpty_ReturnsPrimaryOnly()
|
||||
{
|
||||
@@ -20,6 +22,7 @@ public class FailoverUrlParserTests
|
||||
result.ShouldBe(["opc.tcp://primary:4840"]);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that Parse returns only the primary URL when CSV failover list is whitespace.</summary>
|
||||
[Fact]
|
||||
public void Parse_CsvWhitespace_ReturnsPrimaryOnly()
|
||||
{
|
||||
@@ -27,6 +30,7 @@ public class FailoverUrlParserTests
|
||||
result.ShouldBe(["opc.tcp://primary:4840"]);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that Parse returns both primary and single failover URL.</summary>
|
||||
[Fact]
|
||||
public void Parse_SingleFailover_ReturnsBoth()
|
||||
{
|
||||
@@ -34,6 +38,7 @@ public class FailoverUrlParserTests
|
||||
result.ShouldBe(["opc.tcp://primary:4840", "opc.tcp://backup:4840"]);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that Parse returns primary URL and all failover URLs from CSV list.</summary>
|
||||
[Fact]
|
||||
public void Parse_MultipleFailovers_ReturnsAll()
|
||||
{
|
||||
@@ -41,6 +46,7 @@ public class FailoverUrlParserTests
|
||||
result.ShouldBe(["opc.tcp://primary:4840", "opc.tcp://backup1:4840", "opc.tcp://backup2:4840"]);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that Parse trims leading and trailing whitespace from failover URLs.</summary>
|
||||
[Fact]
|
||||
public void Parse_TrimsWhitespace()
|
||||
{
|
||||
@@ -48,6 +54,7 @@ public class FailoverUrlParserTests
|
||||
result.ShouldBe(["opc.tcp://primary:4840", "opc.tcp://backup:4840"]);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that Parse deduplicates the primary URL if present in the failover list.</summary>
|
||||
[Fact]
|
||||
public void Parse_DeduplicatesPrimaryInFailoverList()
|
||||
{
|
||||
@@ -55,6 +62,7 @@ public class FailoverUrlParserTests
|
||||
result.ShouldBe(["opc.tcp://primary:4840", "opc.tcp://backup:4840"]);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that Parse performs case-insensitive deduplication of URLs.</summary>
|
||||
[Fact]
|
||||
public void Parse_DeduplicatesCaseInsensitive()
|
||||
{
|
||||
@@ -62,6 +70,7 @@ public class FailoverUrlParserTests
|
||||
result.ShouldBe(["opc.tcp://Primary:4840"]);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that Parse returns only the primary URL when array of failover URLs is null.</summary>
|
||||
[Fact]
|
||||
public void Parse_ArrayNull_ReturnsPrimaryOnly()
|
||||
{
|
||||
@@ -69,6 +78,7 @@ public class FailoverUrlParserTests
|
||||
result.ShouldBe(["opc.tcp://primary:4840"]);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that Parse returns only the primary URL when array of failover URLs is empty.</summary>
|
||||
[Fact]
|
||||
public void Parse_ArrayEmpty_ReturnsPrimaryOnly()
|
||||
{
|
||||
@@ -76,6 +86,7 @@ public class FailoverUrlParserTests
|
||||
result.ShouldBe(["opc.tcp://primary:4840"]);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that Parse returns primary URL and all failover URLs from array.</summary>
|
||||
[Fact]
|
||||
public void Parse_ArrayWithUrls_ReturnsAll()
|
||||
{
|
||||
@@ -84,6 +95,7 @@ public class FailoverUrlParserTests
|
||||
result.ShouldBe(["opc.tcp://primary:4840", "opc.tcp://backup1:4840", "opc.tcp://backup2:4840"]);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that Parse deduplicates URLs from array if primary URL is present.</summary>
|
||||
[Fact]
|
||||
public void Parse_ArrayDeduplicates()
|
||||
{
|
||||
@@ -92,6 +104,7 @@ public class FailoverUrlParserTests
|
||||
result.ShouldBe(["opc.tcp://primary:4840", "opc.tcp://backup:4840"]);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that Parse trims whitespace from URLs in array.</summary>
|
||||
[Fact]
|
||||
public void Parse_ArrayTrimsWhitespace()
|
||||
{
|
||||
@@ -100,6 +113,7 @@ public class FailoverUrlParserTests
|
||||
result.ShouldBe(["opc.tcp://primary:4840", "opc.tcp://backup:4840"]);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that Parse skips null and empty URLs from array.</summary>
|
||||
[Fact]
|
||||
public void Parse_ArraySkipsNullAndEmpty()
|
||||
{
|
||||
|
||||
@@ -8,6 +8,9 @@ namespace ZB.MOM.WW.OtOpcUa.Client.Shared.Tests.Helpers;
|
||||
|
||||
public class SecurityModeMapperTests
|
||||
{
|
||||
/// <summary>Verifies ToMessageSecurityMode correctly maps SecurityMode values to OPC UA MessageSecurityMode.</summary>
|
||||
/// <param name="input">The SecurityMode value to map.</param>
|
||||
/// <param name="expected">The expected MessageSecurityMode result.</param>
|
||||
[Theory]
|
||||
[InlineData(SecurityMode.None, MessageSecurityMode.None)]
|
||||
[InlineData(SecurityMode.Sign, MessageSecurityMode.Sign)]
|
||||
@@ -17,6 +20,7 @@ public class SecurityModeMapperTests
|
||||
SecurityModeMapper.ToMessageSecurityMode(input).ShouldBe(expected);
|
||||
}
|
||||
|
||||
/// <summary>Verifies ToMessageSecurityMode throws on invalid SecurityMode values.</summary>
|
||||
[Fact]
|
||||
public void ToMessageSecurityMode_InvalidValue_Throws()
|
||||
{
|
||||
@@ -24,6 +28,9 @@ public class SecurityModeMapperTests
|
||||
SecurityModeMapper.ToMessageSecurityMode((SecurityMode)99));
|
||||
}
|
||||
|
||||
/// <summary>Verifies FromString correctly parses security mode strings (case-insensitive).</summary>
|
||||
/// <param name="input">The security mode string to parse.</param>
|
||||
/// <param name="expected">The expected SecurityMode result.</param>
|
||||
[Theory]
|
||||
[InlineData("none", SecurityMode.None)]
|
||||
[InlineData("None", SecurityMode.None)]
|
||||
@@ -38,18 +45,21 @@ public class SecurityModeMapperTests
|
||||
SecurityModeMapper.FromString(input).ShouldBe(expected);
|
||||
}
|
||||
|
||||
/// <summary>Verifies FromString correctly parses strings with leading and trailing whitespace.</summary>
|
||||
[Fact]
|
||||
public void FromString_WithWhitespace_ParsesCorrectly()
|
||||
{
|
||||
SecurityModeMapper.FromString(" sign ").ShouldBe(SecurityMode.Sign);
|
||||
}
|
||||
|
||||
/// <summary>Verifies FromString throws on unrecognized security mode strings.</summary>
|
||||
[Fact]
|
||||
public void FromString_UnknownValue_Throws()
|
||||
{
|
||||
Should.Throw<ArgumentException>(() => SecurityModeMapper.FromString("invalid"));
|
||||
}
|
||||
|
||||
/// <summary>Verifies FromString returns None when passed a null string.</summary>
|
||||
[Fact]
|
||||
public void FromString_Null_DefaultsToNone()
|
||||
{
|
||||
|
||||
@@ -6,96 +6,112 @@ namespace ZB.MOM.WW.OtOpcUa.Client.Shared.Tests.Helpers;
|
||||
|
||||
public class ValueConverterTests
|
||||
{
|
||||
/// <summary>Verifies that a boolean string "True" is converted to true.</summary>
|
||||
[Fact]
|
||||
public void ConvertValue_Bool_True()
|
||||
{
|
||||
ValueConverter.ConvertValue("True", true).ShouldBe(true);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a boolean string "False" is converted to false.</summary>
|
||||
[Fact]
|
||||
public void ConvertValue_Bool_False()
|
||||
{
|
||||
ValueConverter.ConvertValue("False", false).ShouldBe(false);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a byte value is converted correctly.</summary>
|
||||
[Fact]
|
||||
public void ConvertValue_Byte()
|
||||
{
|
||||
ValueConverter.ConvertValue("255", (byte)0).ShouldBe((byte)255);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a short value is converted correctly.</summary>
|
||||
[Fact]
|
||||
public void ConvertValue_Short()
|
||||
{
|
||||
ValueConverter.ConvertValue("-100", (short)0).ShouldBe((short)-100);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that an unsigned short value is converted correctly.</summary>
|
||||
[Fact]
|
||||
public void ConvertValue_UShort()
|
||||
{
|
||||
ValueConverter.ConvertValue("65535", (ushort)0).ShouldBe((ushort)65535);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that an integer value is converted correctly.</summary>
|
||||
[Fact]
|
||||
public void ConvertValue_Int()
|
||||
{
|
||||
ValueConverter.ConvertValue("42", 0).ShouldBe(42);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that an unsigned integer value is converted correctly.</summary>
|
||||
[Fact]
|
||||
public void ConvertValue_UInt()
|
||||
{
|
||||
ValueConverter.ConvertValue("42", 0u).ShouldBe(42u);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a long value is converted correctly.</summary>
|
||||
[Fact]
|
||||
public void ConvertValue_Long()
|
||||
{
|
||||
ValueConverter.ConvertValue("9999999999", 0L).ShouldBe(9999999999L);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that an unsigned long value is converted correctly.</summary>
|
||||
[Fact]
|
||||
public void ConvertValue_ULong()
|
||||
{
|
||||
ValueConverter.ConvertValue("18446744073709551615", 0UL).ShouldBe(ulong.MaxValue);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a float value is converted correctly.</summary>
|
||||
[Fact]
|
||||
public void ConvertValue_Float()
|
||||
{
|
||||
ValueConverter.ConvertValue("3.14", 0f).ShouldBe(3.14f);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a double value is converted correctly.</summary>
|
||||
[Fact]
|
||||
public void ConvertValue_Double()
|
||||
{
|
||||
ValueConverter.ConvertValue("3.14159", 0.0).ShouldBe(3.14159);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a string value is converted correctly when the current value is a string.</summary>
|
||||
[Fact]
|
||||
public void ConvertValue_String_WhenCurrentIsString()
|
||||
{
|
||||
ValueConverter.ConvertValue("hello", "").ShouldBe("hello");
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a string value is converted correctly when the current value is null.</summary>
|
||||
[Fact]
|
||||
public void ConvertValue_String_WhenCurrentIsNull()
|
||||
{
|
||||
ValueConverter.ConvertValue("hello", null).ShouldBe("hello");
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a string value is converted correctly when the current value is an unknown type.</summary>
|
||||
[Fact]
|
||||
public void ConvertValue_String_WhenCurrentIsUnknownType()
|
||||
{
|
||||
ValueConverter.ConvertValue("hello", new object()).ShouldBe("hello");
|
||||
}
|
||||
|
||||
/// <summary>Verifies that converting an invalid boolean value throws a FormatException.</summary>
|
||||
[Fact]
|
||||
public void ConvertValue_InvalidBool_Throws()
|
||||
{
|
||||
Should.Throw<FormatException>(() => ValueConverter.ConvertValue("notabool", true));
|
||||
}
|
||||
|
||||
/// <summary>Verifies that converting an invalid integer value throws a FormatException with a descriptive message.</summary>
|
||||
[Fact]
|
||||
public void ConvertValue_InvalidInt_ThrowsWithDescription()
|
||||
{
|
||||
@@ -104,6 +120,7 @@ public class ValueConverterTests
|
||||
ex.Message.ShouldContain("notanint");
|
||||
}
|
||||
|
||||
/// <summary>Verifies that an overflow during conversion throws a FormatException.</summary>
|
||||
[Fact]
|
||||
public void ConvertValue_Overflow_ThrowsFormatException()
|
||||
{
|
||||
@@ -114,6 +131,9 @@ public class ValueConverterTests
|
||||
|
||||
// --- Client.Shared-008: Boolean aliases ---
|
||||
|
||||
/// <summary>Verifies that boolean values accept numeric and word aliases.</summary>
|
||||
/// <param name="input">The input string value.</param>
|
||||
/// <param name="expected">The expected boolean value.</param>
|
||||
[Theory]
|
||||
[InlineData("1", true)]
|
||||
[InlineData("0", false)]
|
||||
@@ -130,6 +150,7 @@ public class ValueConverterTests
|
||||
ValueConverter.ConvertValue(input, true).ShouldBe(expected);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that converting an invalid boolean value throws a descriptive FormatException.</summary>
|
||||
[Fact]
|
||||
public void ConvertValue_InvalidBool_ThrowsDescriptiveFormatException()
|
||||
{
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace ZB.MOM.WW.OtOpcUa.Client.Shared.Tests.Models;
|
||||
|
||||
public class ConnectionSettingsTests
|
||||
{
|
||||
/// <summary>Verifies that ConnectionSettings defaults are correct.</summary>
|
||||
[Fact]
|
||||
public void Defaults_AreCorrect()
|
||||
{
|
||||
@@ -24,6 +25,7 @@ public class ConnectionSettingsTests
|
||||
settings.CertificateStorePath.ShouldBe(string.Empty);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that validation throws on null endpoint URL.</summary>
|
||||
[Fact]
|
||||
public void Validate_ThrowsOnNullEndpointUrl()
|
||||
{
|
||||
@@ -32,6 +34,7 @@ public class ConnectionSettingsTests
|
||||
.ParamName.ShouldBe("EndpointUrl");
|
||||
}
|
||||
|
||||
/// <summary>Verifies that validation throws on empty endpoint URL.</summary>
|
||||
[Fact]
|
||||
public void Validate_ThrowsOnEmptyEndpointUrl()
|
||||
{
|
||||
@@ -40,6 +43,7 @@ public class ConnectionSettingsTests
|
||||
.ParamName.ShouldBe("EndpointUrl");
|
||||
}
|
||||
|
||||
/// <summary>Verifies that validation throws on whitespace endpoint URL.</summary>
|
||||
[Fact]
|
||||
public void Validate_ThrowsOnWhitespaceEndpointUrl()
|
||||
{
|
||||
@@ -48,6 +52,7 @@ public class ConnectionSettingsTests
|
||||
.ParamName.ShouldBe("EndpointUrl");
|
||||
}
|
||||
|
||||
/// <summary>Verifies that validation throws on zero timeout.</summary>
|
||||
[Fact]
|
||||
public void Validate_ThrowsOnZeroTimeout()
|
||||
{
|
||||
@@ -60,6 +65,7 @@ public class ConnectionSettingsTests
|
||||
.ParamName.ShouldBe("SessionTimeoutSeconds");
|
||||
}
|
||||
|
||||
/// <summary>Verifies that validation throws on negative timeout.</summary>
|
||||
[Fact]
|
||||
public void Validate_ThrowsOnNegativeTimeout()
|
||||
{
|
||||
@@ -72,6 +78,7 @@ public class ConnectionSettingsTests
|
||||
.ParamName.ShouldBe("SessionTimeoutSeconds");
|
||||
}
|
||||
|
||||
/// <summary>Verifies that validation throws on timeout above 3600 seconds.</summary>
|
||||
[Fact]
|
||||
public void Validate_ThrowsOnTimeoutAbove3600()
|
||||
{
|
||||
@@ -84,6 +91,7 @@ public class ConnectionSettingsTests
|
||||
.ParamName.ShouldBe("SessionTimeoutSeconds");
|
||||
}
|
||||
|
||||
/// <summary>Verifies that validation succeeds with valid settings.</summary>
|
||||
[Fact]
|
||||
public void Validate_SucceedsWithValidSettings()
|
||||
{
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace ZB.MOM.WW.OtOpcUa.Client.Shared.Tests.Models;
|
||||
|
||||
public class ModelConstructionTests
|
||||
{
|
||||
/// <summary>Verifies that BrowseResult constructs correctly with all properties.</summary>
|
||||
[Fact]
|
||||
public void BrowseResult_ConstructsCorrectly()
|
||||
{
|
||||
@@ -19,6 +20,7 @@ public class ModelConstructionTests
|
||||
result.HasChildren.ShouldBeTrue();
|
||||
}
|
||||
|
||||
/// <summary>Verifies that BrowseResult correctly sets HasChildren to false.</summary>
|
||||
[Fact]
|
||||
public void BrowseResult_WithoutChildren()
|
||||
{
|
||||
@@ -26,6 +28,7 @@ public class ModelConstructionTests
|
||||
result.HasChildren.ShouldBeFalse();
|
||||
}
|
||||
|
||||
/// <summary>Verifies that AlarmEventArgs constructs correctly with all properties.</summary>
|
||||
[Fact]
|
||||
public void AlarmEventArgs_ConstructsCorrectly()
|
||||
{
|
||||
@@ -42,6 +45,7 @@ public class ModelConstructionTests
|
||||
args.Time.ShouldBe(time);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that RedundancyInfo constructs correctly with all properties.</summary>
|
||||
[Fact]
|
||||
public void RedundancyInfo_ConstructsCorrectly()
|
||||
{
|
||||
@@ -54,6 +58,7 @@ public class ModelConstructionTests
|
||||
info.ApplicationUri.ShouldBe("urn:server1");
|
||||
}
|
||||
|
||||
/// <summary>Verifies that RedundancyInfo handles empty URIs correctly.</summary>
|
||||
[Fact]
|
||||
public void RedundancyInfo_WithEmptyUris()
|
||||
{
|
||||
@@ -62,6 +67,7 @@ public class ModelConstructionTests
|
||||
info.ApplicationUri.ShouldBeEmpty();
|
||||
}
|
||||
|
||||
/// <summary>Verifies that DataChangedEventArgs constructs correctly with all properties.</summary>
|
||||
[Fact]
|
||||
public void DataChangedEventArgs_ConstructsCorrectly()
|
||||
{
|
||||
@@ -73,6 +79,7 @@ public class ModelConstructionTests
|
||||
args.Value.Value.ShouldBe(42);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that ConnectionStateChangedEventArgs constructs correctly with all properties.</summary>
|
||||
[Fact]
|
||||
public void ConnectionStateChangedEventArgs_ConstructsCorrectly()
|
||||
{
|
||||
@@ -84,6 +91,7 @@ public class ModelConstructionTests
|
||||
args.EndpointUrl.ShouldBe("opc.tcp://localhost:4840");
|
||||
}
|
||||
|
||||
/// <summary>Verifies that ConnectionInfo constructs correctly with all properties.</summary>
|
||||
[Fact]
|
||||
public void ConnectionInfo_ConstructsCorrectly()
|
||||
{
|
||||
@@ -103,6 +111,7 @@ public class ModelConstructionTests
|
||||
info.SessionName.ShouldBe("TestSession");
|
||||
}
|
||||
|
||||
/// <summary>Verifies that SecurityMode enum has the expected number of values.</summary>
|
||||
[Fact]
|
||||
public void SecurityMode_Enum_HasExpectedValues()
|
||||
{
|
||||
@@ -112,6 +121,7 @@ public class ModelConstructionTests
|
||||
((int)SecurityMode.SignAndEncrypt).ShouldBe(2);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that ConnectionState enum has the expected number of values.</summary>
|
||||
[Fact]
|
||||
public void ConnectionState_Enum_HasExpectedValues()
|
||||
{
|
||||
@@ -122,6 +132,7 @@ public class ModelConstructionTests
|
||||
((int)ConnectionState.Reconnecting).ShouldBe(3);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that AggregateType enum has the expected number of values.</summary>
|
||||
[Fact]
|
||||
public void AggregateType_Enum_HasExpectedValues()
|
||||
{
|
||||
|
||||
@@ -16,6 +16,7 @@ public class OpcUaClientServiceTests : IDisposable
|
||||
private readonly OpcUaClientService _service;
|
||||
private readonly FakeSessionFactory _sessionFactory = new();
|
||||
|
||||
/// <summary>Initializes a new test instance with fake dependencies.</summary>
|
||||
public OpcUaClientServiceTests()
|
||||
{
|
||||
_service = new OpcUaClientService(_configFactory, _endpointDiscovery, _sessionFactory);
|
||||
|
||||
Reference in New Issue
Block a user