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:
@@ -12,6 +12,7 @@ public class AlarmsViewModelTests
|
||||
private readonly FakeOpcUaClientService _service;
|
||||
private readonly AlarmsViewModel _vm;
|
||||
|
||||
/// <summary>Initializes a new test instance.</summary>
|
||||
public AlarmsViewModelTests()
|
||||
{
|
||||
_service = new FakeOpcUaClientService();
|
||||
@@ -19,6 +20,7 @@ public class AlarmsViewModelTests
|
||||
_vm = new AlarmsViewModel(_service, dispatcher);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that SubscribeCommand cannot execute when disconnected.</summary>
|
||||
[Fact]
|
||||
public void SubscribeCommand_CannotExecute_WhenDisconnected()
|
||||
{
|
||||
@@ -26,6 +28,7 @@ public class AlarmsViewModelTests
|
||||
_vm.SubscribeCommand.CanExecute(null).ShouldBeFalse();
|
||||
}
|
||||
|
||||
/// <summary>Verifies that SubscribeCommand cannot execute when already subscribed.</summary>
|
||||
[Fact]
|
||||
public void SubscribeCommand_CannotExecute_WhenAlreadySubscribed()
|
||||
{
|
||||
@@ -34,6 +37,7 @@ public class AlarmsViewModelTests
|
||||
_vm.SubscribeCommand.CanExecute(null).ShouldBeFalse();
|
||||
}
|
||||
|
||||
/// <summary>Verifies that SubscribeCommand can execute when connected and not subscribed.</summary>
|
||||
[Fact]
|
||||
public void SubscribeCommand_CanExecute_WhenConnectedAndNotSubscribed()
|
||||
{
|
||||
@@ -42,6 +46,7 @@ public class AlarmsViewModelTests
|
||||
_vm.SubscribeCommand.CanExecute(null).ShouldBeTrue();
|
||||
}
|
||||
|
||||
/// <summary>Verifies that SubscribeCommand sets IsSubscribed flag.</summary>
|
||||
[Fact]
|
||||
public async Task SubscribeCommand_SetsIsSubscribed()
|
||||
{
|
||||
@@ -53,6 +58,7 @@ public class AlarmsViewModelTests
|
||||
_service.SubscribeAlarmsCallCount.ShouldBe(1);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that UnsubscribeCommand cannot execute when not subscribed.</summary>
|
||||
[Fact]
|
||||
public void UnsubscribeCommand_CannotExecute_WhenNotSubscribed()
|
||||
{
|
||||
@@ -61,6 +67,7 @@ public class AlarmsViewModelTests
|
||||
_vm.UnsubscribeCommand.CanExecute(null).ShouldBeFalse();
|
||||
}
|
||||
|
||||
/// <summary>Verifies that UnsubscribeCommand clears IsSubscribed flag.</summary>
|
||||
[Fact]
|
||||
public async Task UnsubscribeCommand_ClearsIsSubscribed()
|
||||
{
|
||||
@@ -73,6 +80,7 @@ public class AlarmsViewModelTests
|
||||
_service.UnsubscribeAlarmsCallCount.ShouldBe(1);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that RefreshCommand calls the service.</summary>
|
||||
[Fact]
|
||||
public async Task RefreshCommand_CallsService()
|
||||
{
|
||||
@@ -84,6 +92,7 @@ public class AlarmsViewModelTests
|
||||
_service.RequestConditionRefreshCallCount.ShouldBe(1);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that RefreshCommand cannot execute when not subscribed.</summary>
|
||||
[Fact]
|
||||
public void RefreshCommand_CannotExecute_WhenNotSubscribed()
|
||||
{
|
||||
@@ -92,6 +101,7 @@ public class AlarmsViewModelTests
|
||||
_vm.RefreshCommand.CanExecute(null).ShouldBeFalse();
|
||||
}
|
||||
|
||||
/// <summary>Verifies that alarm events are added to the collection.</summary>
|
||||
[Fact]
|
||||
public void AlarmEvent_AddsToCollection()
|
||||
{
|
||||
@@ -108,6 +118,7 @@ public class AlarmsViewModelTests
|
||||
_vm.AlarmEvents[0].Message.ShouldBe("Temperature high");
|
||||
}
|
||||
|
||||
/// <summary>Verifies that Clear resets the view model state.</summary>
|
||||
[Fact]
|
||||
public void Clear_ResetsState()
|
||||
{
|
||||
@@ -120,6 +131,7 @@ public class AlarmsViewModelTests
|
||||
_vm.IsSubscribed.ShouldBeFalse();
|
||||
}
|
||||
|
||||
/// <summary>Verifies that Teardown unregisters the event handler.</summary>
|
||||
[Fact]
|
||||
public void Teardown_UnhooksEventHandler()
|
||||
{
|
||||
@@ -133,6 +145,7 @@ public class AlarmsViewModelTests
|
||||
_vm.AlarmEvents.ShouldBeEmpty();
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the default polling interval is 1000ms.</summary>
|
||||
[Fact]
|
||||
public void DefaultInterval_Is1000()
|
||||
{
|
||||
|
||||
@@ -7,12 +7,14 @@ using BrowseResult = ZB.MOM.WW.OtOpcUa.Client.Shared.Models.BrowseResult;
|
||||
|
||||
namespace ZB.MOM.WW.OtOpcUa.Client.UI.Tests;
|
||||
|
||||
/// <summary>Tests for the BrowseTreeViewModel class.</summary>
|
||||
public class BrowseTreeViewModelTests
|
||||
{
|
||||
private readonly SynchronousUiDispatcher _dispatcher;
|
||||
private readonly FakeOpcUaClientService _service;
|
||||
private readonly BrowseTreeViewModel _vm;
|
||||
|
||||
/// <summary>Initializes a new instance of the BrowseTreeViewModelTests class.</summary>
|
||||
public BrowseTreeViewModelTests()
|
||||
{
|
||||
_service = new FakeOpcUaClientService
|
||||
@@ -27,6 +29,7 @@ public class BrowseTreeViewModelTests
|
||||
_vm = new BrowseTreeViewModel(_service, _dispatcher);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that LoadRootsAsync populates root nodes.</summary>
|
||||
[Fact]
|
||||
public async Task LoadRootsAsync_PopulatesRootNodes()
|
||||
{
|
||||
@@ -37,6 +40,7 @@ public class BrowseTreeViewModelTests
|
||||
_vm.RootNodes[1].DisplayName.ShouldBe("Node2");
|
||||
}
|
||||
|
||||
/// <summary>Verifies that LoadRootsAsync browses with null parent.</summary>
|
||||
[Fact]
|
||||
public async Task LoadRootsAsync_BrowsesWithNullParent()
|
||||
{
|
||||
@@ -46,6 +50,7 @@ public class BrowseTreeViewModelTests
|
||||
_service.LastBrowseParentNodeId.ShouldBeNull();
|
||||
}
|
||||
|
||||
/// <summary>Verifies that Clear removes all root nodes.</summary>
|
||||
[Fact]
|
||||
public void Clear_RemovesAllRootNodes()
|
||||
{
|
||||
@@ -55,6 +60,7 @@ public class BrowseTreeViewModelTests
|
||||
_vm.RootNodes.ShouldBeEmpty();
|
||||
}
|
||||
|
||||
/// <summary>Verifies that nodes with children have a placeholder.</summary>
|
||||
[Fact]
|
||||
public async Task LoadRootsAsync_NodeWithChildren_HasPlaceholder()
|
||||
{
|
||||
@@ -66,6 +72,7 @@ public class BrowseTreeViewModelTests
|
||||
nodeWithChildren.Children[0].IsPlaceholder.ShouldBeTrue();
|
||||
}
|
||||
|
||||
/// <summary>Verifies that nodes without children have no placeholder.</summary>
|
||||
[Fact]
|
||||
public async Task LoadRootsAsync_NodeWithoutChildren_HasNoPlaceholder()
|
||||
{
|
||||
@@ -76,6 +83,7 @@ public class BrowseTreeViewModelTests
|
||||
leafNode.Children.ShouldBeEmpty();
|
||||
}
|
||||
|
||||
/// <summary>Verifies that first tree node expand triggers child browse.</summary>
|
||||
[Fact]
|
||||
public async Task TreeNode_FirstExpand_TriggersChildBrowse()
|
||||
{
|
||||
@@ -105,6 +113,7 @@ public class BrowseTreeViewModelTests
|
||||
parent.Children[0].DisplayName.ShouldBe("Child1");
|
||||
}
|
||||
|
||||
/// <summary>Verifies that second tree node expand does not browse again.</summary>
|
||||
[Fact]
|
||||
public async Task TreeNode_SecondExpand_DoesNotBrowseAgain()
|
||||
{
|
||||
@@ -133,6 +142,7 @@ public class BrowseTreeViewModelTests
|
||||
_service.BrowseCallCount.ShouldBe(browseCountAfterFirst);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that IsLoading transitions during browse.</summary>
|
||||
[Fact]
|
||||
public async Task TreeNode_IsLoading_TransitionsDuringBrowse()
|
||||
{
|
||||
|
||||
@@ -84,28 +84,50 @@ public sealed class FakeOpcUaClientService : IOpcUaClientService
|
||||
public Exception? HistoryException { get; set; }
|
||||
|
||||
// Call tracking
|
||||
/// <summary>Gets the number of times ConnectAsync has been called.</summary>
|
||||
public int ConnectCallCount { get; private set; }
|
||||
/// <summary>Gets the number of times DisconnectAsync has been called.</summary>
|
||||
public int DisconnectCallCount { get; private set; }
|
||||
/// <summary>Gets the number of times ReadValueAsync has been called.</summary>
|
||||
public int ReadCallCount { get; private set; }
|
||||
/// <summary>Gets the number of times WriteValueAsync has been called.</summary>
|
||||
public int WriteCallCount { get; private set; }
|
||||
/// <summary>Gets the number of times BrowseAsync has been called.</summary>
|
||||
public int BrowseCallCount { get; private set; }
|
||||
/// <summary>Gets the number of times SubscribeAsync has been called.</summary>
|
||||
public int SubscribeCallCount { get; private set; }
|
||||
/// <summary>Gets the number of times UnsubscribeAsync has been called.</summary>
|
||||
public int UnsubscribeCallCount { get; private set; }
|
||||
/// <summary>Gets the number of times SubscribeAlarmsAsync has been called.</summary>
|
||||
public int SubscribeAlarmsCallCount { get; private set; }
|
||||
/// <summary>Gets the number of times UnsubscribeAlarmsAsync has been called.</summary>
|
||||
public int UnsubscribeAlarmsCallCount { get; private set; }
|
||||
/// <summary>Gets the number of times RequestConditionRefreshAsync has been called.</summary>
|
||||
public int RequestConditionRefreshCallCount { get; private set; }
|
||||
/// <summary>Gets the number of times HistoryReadRawAsync has been called.</summary>
|
||||
public int HistoryReadRawCallCount { get; private set; }
|
||||
/// <summary>Gets the number of times HistoryReadAggregateAsync has been called.</summary>
|
||||
public int HistoryReadAggregateCallCount { get; private set; }
|
||||
/// <summary>Gets the number of times GetRedundancyInfoAsync has been called.</summary>
|
||||
public int GetRedundancyInfoCallCount { get; private set; }
|
||||
|
||||
/// <summary>Gets the connection settings from the last ConnectAsync call.</summary>
|
||||
public ConnectionSettings? LastConnectionSettings { get; private set; }
|
||||
/// <summary>Gets the node ID from the last ReadValueAsync call.</summary>
|
||||
public NodeId? LastReadNodeId { get; private set; }
|
||||
/// <summary>Gets the node ID from the last WriteValueAsync call.</summary>
|
||||
public NodeId? LastWriteNodeId { get; private set; }
|
||||
/// <summary>Gets the value from the last WriteValueAsync call.</summary>
|
||||
public object? LastWriteValue { get; private set; }
|
||||
/// <summary>Gets the parent node ID from the last BrowseAsync call.</summary>
|
||||
public NodeId? LastBrowseParentNodeId { get; private set; }
|
||||
/// <summary>Gets the node ID from the last SubscribeAsync call.</summary>
|
||||
public NodeId? LastSubscribeNodeId { get; private set; }
|
||||
/// <summary>Gets the interval in milliseconds from the last SubscribeAsync call.</summary>
|
||||
public int LastSubscribeIntervalMs { get; private set; }
|
||||
/// <summary>Gets the node ID from the last UnsubscribeAsync call.</summary>
|
||||
public NodeId? LastUnsubscribeNodeId { get; private set; }
|
||||
/// <summary>Gets the aggregate type from the last HistoryReadAggregateAsync call.</summary>
|
||||
public AggregateType? LastAggregateType { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -225,8 +247,11 @@ public sealed class FakeOpcUaClientService : IOpcUaClientService
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
/// <summary>Gets or sets the status code returned by acknowledgment operations in UI tests.</summary>
|
||||
public StatusCode AcknowledgeResult { get; set; } = StatusCodes.Good;
|
||||
/// <summary>Gets or sets the exception thrown to simulate alarm acknowledgment failures in the UI.</summary>
|
||||
public Exception? AcknowledgeException { get; set; }
|
||||
/// <summary>Gets the number of times AcknowledgeAlarmAsync has been called.</summary>
|
||||
public int AcknowledgeCallCount { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -276,6 +301,7 @@ public sealed class FakeOpcUaClientService : IOpcUaClientService
|
||||
/// <summary>
|
||||
/// Raises a simulated data-change notification so UI tests can validate live update handling.
|
||||
/// </summary>
|
||||
/// <param name="args">The data change event arguments to raise.</param>
|
||||
public void RaiseDataChanged(DataChangedEventArgs args)
|
||||
{
|
||||
DataChanged?.Invoke(this, args);
|
||||
@@ -284,6 +310,7 @@ public sealed class FakeOpcUaClientService : IOpcUaClientService
|
||||
/// <summary>
|
||||
/// Raises a simulated alarm event so UI tests can validate alarm-list behavior.
|
||||
/// </summary>
|
||||
/// <param name="args">The alarm event arguments to raise.</param>
|
||||
public void RaiseAlarmEvent(AlarmEventArgs args)
|
||||
{
|
||||
AlarmEvent?.Invoke(this, args);
|
||||
@@ -292,6 +319,7 @@ public sealed class FakeOpcUaClientService : IOpcUaClientService
|
||||
/// <summary>
|
||||
/// Raises a simulated connection-state transition so UI tests can validate status presentation and failover behavior.
|
||||
/// </summary>
|
||||
/// <param name="args">The connection state changed event arguments to raise.</param>
|
||||
public void RaiseConnectionStateChanged(ConnectionStateChangedEventArgs args)
|
||||
{
|
||||
ConnectionStateChanged?.Invoke(this, args);
|
||||
|
||||
@@ -9,11 +9,15 @@ public sealed class FakeOpcUaClientServiceFactory : IOpcUaClientServiceFactory
|
||||
{
|
||||
private readonly FakeOpcUaClientService _service;
|
||||
|
||||
/// <summary>Initializes a new instance of FakeOpcUaClientServiceFactory.</summary>
|
||||
/// <param name="service">The fake OPC UA client service to return.</param>
|
||||
public FakeOpcUaClientServiceFactory(FakeOpcUaClientService service)
|
||||
{
|
||||
_service = service;
|
||||
}
|
||||
|
||||
/// <summary>Creates an OPC UA client service instance.</summary>
|
||||
/// <returns>The preconfigured fake OPC UA client service.</returns>
|
||||
public IOpcUaClientService Create()
|
||||
{
|
||||
return _service;
|
||||
|
||||
@@ -4,17 +4,24 @@ namespace ZB.MOM.WW.OtOpcUa.Client.UI.Tests.Fakes;
|
||||
|
||||
public sealed class FakeSettingsService : ISettingsService
|
||||
{
|
||||
/// <summary>Gets or sets the settings held by this fake service.</summary>
|
||||
public UserSettings Settings { get; set; } = new();
|
||||
/// <summary>Gets the number of times Load has been called.</summary>
|
||||
public int LoadCallCount { get; private set; }
|
||||
/// <summary>Gets the number of times Save has been called.</summary>
|
||||
public int SaveCallCount { get; private set; }
|
||||
/// <summary>Gets the last settings that were saved.</summary>
|
||||
public UserSettings? LastSaved { get; private set; }
|
||||
|
||||
/// <summary>Loads and returns the current settings.</summary>
|
||||
public UserSettings Load()
|
||||
{
|
||||
LoadCallCount++;
|
||||
return Settings;
|
||||
}
|
||||
|
||||
/// <summary>Saves the specified settings.</summary>
|
||||
/// <param name="settings">The settings to save.</param>
|
||||
public void Save(UserSettings settings)
|
||||
{
|
||||
SaveCallCount++;
|
||||
|
||||
@@ -13,6 +13,7 @@ public class HistoryViewModelTests
|
||||
private readonly FakeOpcUaClientService _service;
|
||||
private readonly HistoryViewModel _vm;
|
||||
|
||||
/// <summary>Initializes a new instance of the <see cref="HistoryViewModelTests"/> class.</summary>
|
||||
public HistoryViewModelTests()
|
||||
{
|
||||
_service = new FakeOpcUaClientService
|
||||
@@ -31,6 +32,7 @@ public class HistoryViewModelTests
|
||||
_vm = new HistoryViewModel(_service, dispatcher);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the read history command cannot execute when disconnected.</summary>
|
||||
[Fact]
|
||||
public void ReadHistoryCommand_CannotExecute_WhenDisconnected()
|
||||
{
|
||||
@@ -39,6 +41,7 @@ public class HistoryViewModelTests
|
||||
_vm.ReadHistoryCommand.CanExecute(null).ShouldBeFalse();
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the read history command cannot execute when no node is selected.</summary>
|
||||
[Fact]
|
||||
public void ReadHistoryCommand_CannotExecute_WhenNoNodeSelected()
|
||||
{
|
||||
@@ -47,6 +50,7 @@ public class HistoryViewModelTests
|
||||
_vm.ReadHistoryCommand.CanExecute(null).ShouldBeFalse();
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the read history command can execute when connected and a node is selected.</summary>
|
||||
[Fact]
|
||||
public void ReadHistoryCommand_CanExecute_WhenConnectedAndNodeSelected()
|
||||
{
|
||||
@@ -55,6 +59,7 @@ public class HistoryViewModelTests
|
||||
_vm.ReadHistoryCommand.CanExecute(null).ShouldBeTrue();
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a raw history read populates results correctly.</summary>
|
||||
[Fact]
|
||||
public async Task ReadHistoryCommand_Raw_PopulatesResults()
|
||||
{
|
||||
@@ -71,6 +76,7 @@ public class HistoryViewModelTests
|
||||
_service.HistoryReadAggregateCallCount.ShouldBe(0);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that an aggregate history read populates results correctly.</summary>
|
||||
[Fact]
|
||||
public async Task ReadHistoryCommand_Aggregate_PopulatesResults()
|
||||
{
|
||||
@@ -87,6 +93,7 @@ public class HistoryViewModelTests
|
||||
_service.HistoryReadRawCallCount.ShouldBe(0);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the read history command clears previous results before loading new ones.</summary>
|
||||
[Fact]
|
||||
public async Task ReadHistoryCommand_ClearsResultsBefore()
|
||||
{
|
||||
@@ -99,6 +106,7 @@ public class HistoryViewModelTests
|
||||
_vm.Results.ShouldNotContain(r => r.Value == "old");
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the loading state is false after the read history command completes.</summary>
|
||||
[Fact]
|
||||
public async Task ReadHistoryCommand_IsLoading_FalseAfterComplete()
|
||||
{
|
||||
@@ -110,6 +118,7 @@ public class HistoryViewModelTests
|
||||
_vm.IsLoading.ShouldBeFalse();
|
||||
}
|
||||
|
||||
/// <summary>Verifies that default values are initialized correctly.</summary>
|
||||
[Fact]
|
||||
public void DefaultValues_AreCorrect()
|
||||
{
|
||||
@@ -119,6 +128,7 @@ public class HistoryViewModelTests
|
||||
_vm.IsAggregateRead.ShouldBeFalse();
|
||||
}
|
||||
|
||||
/// <summary>Verifies that IsAggregateRead returns true when an aggregate type is selected.</summary>
|
||||
[Fact]
|
||||
public void IsAggregateRead_TrueWhenAggregateSelected()
|
||||
{
|
||||
@@ -126,6 +136,7 @@ public class HistoryViewModelTests
|
||||
_vm.IsAggregateRead.ShouldBeTrue();
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the aggregate types collection contains null for raw reads.</summary>
|
||||
[Fact]
|
||||
public void AggregateTypes_ContainsNullForRaw()
|
||||
{
|
||||
@@ -133,6 +144,7 @@ public class HistoryViewModelTests
|
||||
_vm.AggregateTypes.Count.ShouldBe(8); // null + 7 enum values
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the Clear method resets the view model state.</summary>
|
||||
[Fact]
|
||||
public void Clear_ResetsState()
|
||||
{
|
||||
@@ -145,6 +157,7 @@ public class HistoryViewModelTests
|
||||
_vm.SelectedNodeId.ShouldBeNull();
|
||||
}
|
||||
|
||||
/// <summary>Verifies that read history command errors are displayed in the results.</summary>
|
||||
[Fact]
|
||||
public async Task ReadHistoryCommand_Error_ShowsErrorInResults()
|
||||
{
|
||||
|
||||
@@ -18,6 +18,7 @@ public class MainWindowViewModelTests
|
||||
private readonly FakeSettingsService _settingsService;
|
||||
private readonly MainWindowViewModel _vm;
|
||||
|
||||
/// <summary>Initializes test fixtures with default client and settings services.</summary>
|
||||
public MainWindowViewModelTests()
|
||||
{
|
||||
_service = new FakeOpcUaClientService
|
||||
|
||||
@@ -12,6 +12,7 @@ public class ReadWriteViewModelTests
|
||||
private readonly FakeOpcUaClientService _service;
|
||||
private readonly ReadWriteViewModel _vm;
|
||||
|
||||
/// <summary>Initializes a new instance of the ReadWriteViewModelTests class.</summary>
|
||||
public ReadWriteViewModelTests()
|
||||
{
|
||||
_service = new FakeOpcUaClientService
|
||||
@@ -22,6 +23,7 @@ public class ReadWriteViewModelTests
|
||||
_vm = new ReadWriteViewModel(_service, dispatcher);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the read command cannot execute when disconnected.</summary>
|
||||
[Fact]
|
||||
public void ReadCommand_CannotExecute_WhenDisconnected()
|
||||
{
|
||||
@@ -30,6 +32,7 @@ public class ReadWriteViewModelTests
|
||||
_vm.ReadCommand.CanExecute(null).ShouldBeFalse();
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the read command cannot execute when no node is selected.</summary>
|
||||
[Fact]
|
||||
public void ReadCommand_CannotExecute_WhenNoNodeSelected()
|
||||
{
|
||||
@@ -38,6 +41,7 @@ public class ReadWriteViewModelTests
|
||||
_vm.ReadCommand.CanExecute(null).ShouldBeFalse();
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the read command can execute when connected and a node is selected.</summary>
|
||||
[Fact]
|
||||
public void ReadCommand_CanExecute_WhenConnectedAndNodeSelected()
|
||||
{
|
||||
@@ -46,6 +50,7 @@ public class ReadWriteViewModelTests
|
||||
_vm.ReadCommand.CanExecute(null).ShouldBeTrue();
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the read command updates value and status.</summary>
|
||||
[Fact]
|
||||
public async Task ReadCommand_UpdatesValueAndStatus()
|
||||
{
|
||||
@@ -63,6 +68,7 @@ public class ReadWriteViewModelTests
|
||||
(_service.ReadCallCount - countBefore).ShouldBe(1);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that auto-read fires on selection change when connected.</summary>
|
||||
[Fact]
|
||||
public void AutoRead_OnSelectionChange_WhenConnected()
|
||||
{
|
||||
@@ -74,6 +80,7 @@ public class ReadWriteViewModelTests
|
||||
_service.ReadCallCount.ShouldBeGreaterThanOrEqualTo(1);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that null selection does not call the service.</summary>
|
||||
[Fact]
|
||||
public void NullSelection_DoesNotCallService()
|
||||
{
|
||||
@@ -83,6 +90,7 @@ public class ReadWriteViewModelTests
|
||||
_service.ReadCallCount.ShouldBe(0);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the write command updates write status.</summary>
|
||||
[Fact]
|
||||
public async Task WriteCommand_UpdatesWriteStatus()
|
||||
{
|
||||
@@ -100,6 +108,7 @@ public class ReadWriteViewModelTests
|
||||
_service.LastWriteValue.ShouldBe("NewValue");
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the write command cannot execute when disconnected.</summary>
|
||||
[Fact]
|
||||
public void WriteCommand_CannotExecute_WhenDisconnected()
|
||||
{
|
||||
@@ -108,6 +117,7 @@ public class ReadWriteViewModelTests
|
||||
_vm.WriteCommand.CanExecute(null).ShouldBeFalse();
|
||||
}
|
||||
|
||||
/// <summary>Verifies that read command error sets error status.</summary>
|
||||
[Fact]
|
||||
public async Task ReadCommand_Error_SetsErrorStatus()
|
||||
{
|
||||
@@ -121,6 +131,7 @@ public class ReadWriteViewModelTests
|
||||
_vm.CurrentStatus.ShouldContain("Error");
|
||||
}
|
||||
|
||||
/// <summary>Verifies that clear resets all properties.</summary>
|
||||
[Fact]
|
||||
public void Clear_ResetsAllProperties()
|
||||
{
|
||||
@@ -140,6 +151,7 @@ public class ReadWriteViewModelTests
|
||||
_vm.WriteStatus.ShouldBeNull();
|
||||
}
|
||||
|
||||
/// <summary>Verifies that IsNodeSelected tracks the selected node ID.</summary>
|
||||
[Fact]
|
||||
public void IsNodeSelected_TracksSelectedNodeId()
|
||||
{
|
||||
|
||||
@@ -14,6 +14,7 @@ public class SubscriptionsViewModelTests
|
||||
private readonly FakeOpcUaClientService _service;
|
||||
private readonly SubscriptionsViewModel _vm;
|
||||
|
||||
/// <summary>Initializes test instance with fake services.</summary>
|
||||
public SubscriptionsViewModelTests()
|
||||
{
|
||||
_service = new FakeOpcUaClientService();
|
||||
@@ -21,6 +22,7 @@ public class SubscriptionsViewModelTests
|
||||
_vm = new SubscriptionsViewModel(_service, dispatcher);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that AddSubscriptionCommand cannot execute when disconnected.</summary>
|
||||
[Fact]
|
||||
public void AddSubscriptionCommand_CannotExecute_WhenDisconnected()
|
||||
{
|
||||
@@ -29,6 +31,7 @@ public class SubscriptionsViewModelTests
|
||||
_vm.AddSubscriptionCommand.CanExecute(null).ShouldBeFalse();
|
||||
}
|
||||
|
||||
/// <summary>Verifies that AddSubscriptionCommand cannot execute without a node ID.</summary>
|
||||
[Fact]
|
||||
public void AddSubscriptionCommand_CannotExecute_WhenNoNodeId()
|
||||
{
|
||||
@@ -37,6 +40,7 @@ public class SubscriptionsViewModelTests
|
||||
_vm.AddSubscriptionCommand.CanExecute(null).ShouldBeFalse();
|
||||
}
|
||||
|
||||
/// <summary>Verifies that AddSubscriptionCommand adds a new subscription to the active list.</summary>
|
||||
[Fact]
|
||||
public async Task AddSubscriptionCommand_AddsItem()
|
||||
{
|
||||
@@ -53,6 +57,7 @@ public class SubscriptionsViewModelTests
|
||||
_service.SubscribeCallCount.ShouldBe(1);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that RemoveSubscriptionCommand removes selected subscription.</summary>
|
||||
[Fact]
|
||||
public async Task RemoveSubscriptionCommand_RemovesItem()
|
||||
{
|
||||
@@ -68,6 +73,7 @@ public class SubscriptionsViewModelTests
|
||||
_service.UnsubscribeCallCount.ShouldBe(1);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that RemoveSubscriptionCommand cannot execute without selection.</summary>
|
||||
[Fact]
|
||||
public void RemoveSubscriptionCommand_CannotExecute_WhenNoSelection()
|
||||
{
|
||||
@@ -76,6 +82,7 @@ public class SubscriptionsViewModelTests
|
||||
_vm.RemoveSubscriptionCommand.CanExecute(null).ShouldBeFalse();
|
||||
}
|
||||
|
||||
/// <summary>Verifies that DataChanged event updates the matching subscription row.</summary>
|
||||
[Fact]
|
||||
public async Task DataChanged_UpdatesMatchingRow()
|
||||
{
|
||||
@@ -90,6 +97,7 @@ public class SubscriptionsViewModelTests
|
||||
_vm.ActiveSubscriptions[0].Status.ShouldNotBeNull();
|
||||
}
|
||||
|
||||
/// <summary>Verifies that DataChanged event does not update non-matching subscription rows.</summary>
|
||||
[Fact]
|
||||
public async Task DataChanged_DoesNotUpdateNonMatchingRow()
|
||||
{
|
||||
@@ -103,6 +111,7 @@ public class SubscriptionsViewModelTests
|
||||
_vm.ActiveSubscriptions[0].Value.ShouldBeNull();
|
||||
}
|
||||
|
||||
/// <summary>Verifies that Clear removes all subscriptions.</summary>
|
||||
[Fact]
|
||||
public void Clear_RemovesAllSubscriptions()
|
||||
{
|
||||
@@ -115,6 +124,7 @@ public class SubscriptionsViewModelTests
|
||||
_vm.SubscriptionCount.ShouldBe(0);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that Teardown unregisters the event handler.</summary>
|
||||
[Fact]
|
||||
public void Teardown_UnhooksEventHandler()
|
||||
{
|
||||
@@ -128,12 +138,14 @@ public class SubscriptionsViewModelTests
|
||||
_vm.ActiveSubscriptions[0].Value.ShouldBeNull();
|
||||
}
|
||||
|
||||
/// <summary>Verifies that default interval is 1000 milliseconds.</summary>
|
||||
[Fact]
|
||||
public void DefaultInterval_Is1000()
|
||||
{
|
||||
_vm.NewInterval.ShouldBe(1000);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that AddSubscriptionForNodeAsync adds a subscription.</summary>
|
||||
[Fact]
|
||||
public async Task AddSubscriptionForNodeAsync_AddsSubscription()
|
||||
{
|
||||
@@ -147,6 +159,7 @@ public class SubscriptionsViewModelTests
|
||||
_service.SubscribeCallCount.ShouldBe(1);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that AddSubscriptionForNodeAsync skips duplicate subscriptions.</summary>
|
||||
[Fact]
|
||||
public async Task AddSubscriptionForNodeAsync_SkipsDuplicate()
|
||||
{
|
||||
@@ -159,6 +172,7 @@ public class SubscriptionsViewModelTests
|
||||
_service.SubscribeCallCount.ShouldBe(1);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that AddSubscriptionForNodeAsync does nothing when disconnected.</summary>
|
||||
[Fact]
|
||||
public async Task AddSubscriptionForNodeAsync_DoesNothing_WhenDisconnected()
|
||||
{
|
||||
@@ -170,6 +184,7 @@ public class SubscriptionsViewModelTests
|
||||
_service.SubscribeCallCount.ShouldBe(0);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that GetSubscribedNodeIds returns all active subscription node IDs.</summary>
|
||||
[Fact]
|
||||
public async Task GetSubscribedNodeIds_ReturnsActiveNodeIds()
|
||||
{
|
||||
@@ -184,6 +199,7 @@ public class SubscriptionsViewModelTests
|
||||
ids.ShouldContain("ns=2;s=Node2");
|
||||
}
|
||||
|
||||
/// <summary>Verifies that RestoreSubscriptionsAsync subscribes to all provided node IDs.</summary>
|
||||
[Fact]
|
||||
public async Task RestoreSubscriptionsAsync_SubscribesAllNodes()
|
||||
{
|
||||
@@ -195,6 +211,7 @@ public class SubscriptionsViewModelTests
|
||||
_service.SubscribeCallCount.ShouldBe(2);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that ValidateAndWriteAsync returns true on successful write.</summary>
|
||||
[Fact]
|
||||
public async Task ValidateAndWriteAsync_SuccessReturnsTrue()
|
||||
{
|
||||
@@ -209,6 +226,7 @@ public class SubscriptionsViewModelTests
|
||||
_service.WriteCallCount.ShouldBe(1);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that ValidateAndWriteAsync returns false when value parsing fails.</summary>
|
||||
[Fact]
|
||||
public async Task ValidateAndWriteAsync_ParseFailureReturnsFalse()
|
||||
{
|
||||
@@ -223,6 +241,7 @@ public class SubscriptionsViewModelTests
|
||||
_service.WriteCallCount.ShouldBe(0);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that ValidateAndWriteAsync returns false when write fails.</summary>
|
||||
[Fact]
|
||||
public async Task ValidateAndWriteAsync_WriteFailureReturnsFalse()
|
||||
{
|
||||
@@ -236,6 +255,7 @@ public class SubscriptionsViewModelTests
|
||||
message.ShouldContain("Access denied");
|
||||
}
|
||||
|
||||
/// <summary>Verifies that ValidateAndWriteAsync returns false when status is bad.</summary>
|
||||
[Fact]
|
||||
public async Task ValidateAndWriteAsync_BadStatusReturnsFalse()
|
||||
{
|
||||
@@ -249,6 +269,7 @@ public class SubscriptionsViewModelTests
|
||||
message.ShouldContain("Write failed");
|
||||
}
|
||||
|
||||
/// <summary>Verifies that AddSubscriptionRecursiveAsync subscribes a variable directly.</summary>
|
||||
[Fact]
|
||||
public async Task AddSubscriptionRecursiveAsync_SubscribesVariableDirectly()
|
||||
{
|
||||
@@ -260,6 +281,7 @@ public class SubscriptionsViewModelTests
|
||||
_vm.ActiveSubscriptions[0].NodeId.ShouldBe("ns=2;s=Var1");
|
||||
}
|
||||
|
||||
/// <summary>Verifies that AddSubscriptionRecursiveAsync browses objects and subscribes variable children.</summary>
|
||||
[Fact]
|
||||
public async Task AddSubscriptionRecursiveAsync_BrowsesObjectAndSubscribesVariableChildren()
|
||||
{
|
||||
@@ -311,6 +333,7 @@ public class SubscriptionsViewModelTests
|
||||
_vm.StatusMessage.ShouldContain("Bad node id");
|
||||
}
|
||||
|
||||
/// <summary>Verifies that AddSubscriptionRecursiveAsync recurses through nested objects.</summary>
|
||||
[Fact]
|
||||
public async Task AddSubscriptionRecursiveAsync_RecursesNestedObjects()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user