Apply code style formatting and restore partial modifiers on Avalonia views
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>
This commit is contained in:
@@ -138,4 +138,4 @@ public class AlarmsViewModelTests
|
||||
{
|
||||
_vm.Interval.ShouldBe(1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,19 +9,19 @@ namespace ZB.MOM.WW.LmxOpcUa.Client.UI.Tests;
|
||||
|
||||
public class BrowseTreeViewModelTests
|
||||
{
|
||||
private readonly FakeOpcUaClientService _service;
|
||||
private readonly SynchronousUiDispatcher _dispatcher;
|
||||
private readonly FakeOpcUaClientService _service;
|
||||
private readonly BrowseTreeViewModel _vm;
|
||||
|
||||
public BrowseTreeViewModelTests()
|
||||
{
|
||||
_service = new FakeOpcUaClientService
|
||||
{
|
||||
BrowseResults = new[]
|
||||
{
|
||||
BrowseResults =
|
||||
[
|
||||
new BrowseResult("ns=2;s=Node1", "Node1", "Object", true),
|
||||
new BrowseResult("ns=2;s=Node2", "Node2", "Variable", false)
|
||||
}
|
||||
]
|
||||
};
|
||||
_dispatcher = new SynchronousUiDispatcher();
|
||||
_vm = new BrowseTreeViewModel(_service, _dispatcher);
|
||||
@@ -79,18 +79,18 @@ public class BrowseTreeViewModelTests
|
||||
[Fact]
|
||||
public async Task TreeNode_FirstExpand_TriggersChildBrowse()
|
||||
{
|
||||
_service.BrowseResults = new[]
|
||||
{
|
||||
_service.BrowseResults =
|
||||
[
|
||||
new BrowseResult("ns=2;s=Parent", "Parent", "Object", true)
|
||||
};
|
||||
];
|
||||
|
||||
await _vm.LoadRootsAsync();
|
||||
|
||||
// Reset browse results for child browse
|
||||
_service.BrowseResults = new[]
|
||||
{
|
||||
_service.BrowseResults =
|
||||
[
|
||||
new BrowseResult("ns=2;s=Child1", "Child1", "Variable", false)
|
||||
};
|
||||
];
|
||||
|
||||
var parent = _vm.RootNodes[0];
|
||||
var initialBrowseCount = _service.BrowseCallCount;
|
||||
@@ -108,17 +108,17 @@ public class BrowseTreeViewModelTests
|
||||
[Fact]
|
||||
public async Task TreeNode_SecondExpand_DoesNotBrowseAgain()
|
||||
{
|
||||
_service.BrowseResults = new[]
|
||||
{
|
||||
_service.BrowseResults =
|
||||
[
|
||||
new BrowseResult("ns=2;s=Parent", "Parent", "Object", true)
|
||||
};
|
||||
];
|
||||
|
||||
await _vm.LoadRootsAsync();
|
||||
|
||||
_service.BrowseResults = new[]
|
||||
{
|
||||
_service.BrowseResults =
|
||||
[
|
||||
new BrowseResult("ns=2;s=Child1", "Child1", "Variable", false)
|
||||
};
|
||||
];
|
||||
|
||||
var parent = _vm.RootNodes[0];
|
||||
parent.IsExpanded = true;
|
||||
@@ -136,14 +136,14 @@ public class BrowseTreeViewModelTests
|
||||
[Fact]
|
||||
public async Task TreeNode_IsLoading_TransitionsDuringBrowse()
|
||||
{
|
||||
_service.BrowseResults = new[]
|
||||
{
|
||||
_service.BrowseResults =
|
||||
[
|
||||
new BrowseResult("ns=2;s=Parent", "Parent", "Object", true)
|
||||
};
|
||||
];
|
||||
|
||||
await _vm.LoadRootsAsync();
|
||||
|
||||
_service.BrowseResults = Array.Empty<BrowseResult>();
|
||||
_service.BrowseResults = [];
|
||||
|
||||
var parent = _vm.RootNodes[0];
|
||||
parent.IsExpanded = true;
|
||||
@@ -152,4 +152,4 @@ public class BrowseTreeViewModelTests
|
||||
// After completion, IsLoading should be false
|
||||
parent.IsLoading.ShouldBeFalse();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,28 +2,30 @@ using Opc.Ua;
|
||||
using ZB.MOM.WW.LmxOpcUa.Client.Shared;
|
||||
using ZB.MOM.WW.LmxOpcUa.Client.Shared.Models;
|
||||
using BrowseResult = ZB.MOM.WW.LmxOpcUa.Client.Shared.Models.BrowseResult;
|
||||
using ConnectionState = ZB.MOM.WW.LmxOpcUa.Client.Shared.Models.ConnectionState;
|
||||
|
||||
namespace ZB.MOM.WW.LmxOpcUa.Client.UI.Tests.Fakes;
|
||||
|
||||
/// <summary>
|
||||
/// Fake IOpcUaClientService for unit testing.
|
||||
/// Fake IOpcUaClientService for unit testing.
|
||||
/// </summary>
|
||||
public sealed class FakeOpcUaClientService : IOpcUaClientService
|
||||
{
|
||||
// Configurable responses
|
||||
public ConnectionInfo? ConnectResult { get; set; }
|
||||
public Exception? ConnectException { get; set; }
|
||||
public IReadOnlyList<BrowseResult> BrowseResults { get; set; } = Array.Empty<BrowseResult>();
|
||||
public IReadOnlyList<BrowseResult> BrowseResults { get; set; } = [];
|
||||
public Exception? BrowseException { get; set; }
|
||||
public DataValue ReadResult { get; set; } = new DataValue(new Variant(42), StatusCodes.Good, DateTime.UtcNow, DateTime.UtcNow);
|
||||
|
||||
public DataValue ReadResult { get; set; } =
|
||||
new(new Variant(42), StatusCodes.Good, DateTime.UtcNow, DateTime.UtcNow);
|
||||
|
||||
public Exception? ReadException { get; set; }
|
||||
public StatusCode WriteResult { get; set; } = StatusCodes.Good;
|
||||
public Exception? WriteException { get; set; }
|
||||
public RedundancyInfo? RedundancyResult { get; set; }
|
||||
public Exception? RedundancyException { get; set; }
|
||||
public IReadOnlyList<DataValue> HistoryRawResult { get; set; } = Array.Empty<DataValue>();
|
||||
public IReadOnlyList<DataValue> HistoryAggregateResult { get; set; } = Array.Empty<DataValue>();
|
||||
public IReadOnlyList<DataValue> HistoryRawResult { get; set; } = [];
|
||||
public IReadOnlyList<DataValue> HistoryAggregateResult { get; set; } = [];
|
||||
public Exception? HistoryException { get; set; }
|
||||
|
||||
// Call tracking
|
||||
@@ -134,14 +136,16 @@ public sealed class FakeOpcUaClientService : IOpcUaClientService
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task<IReadOnlyList<DataValue>> HistoryReadRawAsync(NodeId nodeId, DateTime startTime, DateTime endTime, int maxValues = 1000, CancellationToken ct = default)
|
||||
public Task<IReadOnlyList<DataValue>> HistoryReadRawAsync(NodeId nodeId, DateTime startTime, DateTime endTime,
|
||||
int maxValues = 1000, CancellationToken ct = default)
|
||||
{
|
||||
HistoryReadRawCallCount++;
|
||||
if (HistoryException != null) throw HistoryException;
|
||||
return Task.FromResult(HistoryRawResult);
|
||||
}
|
||||
|
||||
public Task<IReadOnlyList<DataValue>> HistoryReadAggregateAsync(NodeId nodeId, DateTime startTime, DateTime endTime, AggregateType aggregate, double intervalMs = 3600000, CancellationToken ct = default)
|
||||
public Task<IReadOnlyList<DataValue>> HistoryReadAggregateAsync(NodeId nodeId, DateTime startTime, DateTime endTime,
|
||||
AggregateType aggregate, double intervalMs = 3600000, CancellationToken ct = default)
|
||||
{
|
||||
HistoryReadAggregateCallCount++;
|
||||
LastAggregateType = aggregate;
|
||||
@@ -156,13 +160,24 @@ public sealed class FakeOpcUaClientService : IOpcUaClientService
|
||||
return Task.FromResult(RedundancyResult!);
|
||||
}
|
||||
|
||||
// Methods to raise events from tests
|
||||
public void RaiseDataChanged(DataChangedEventArgs args) => DataChanged?.Invoke(this, args);
|
||||
public void RaiseAlarmEvent(AlarmEventArgs args) => AlarmEvent?.Invoke(this, args);
|
||||
public void RaiseConnectionStateChanged(ConnectionStateChangedEventArgs args) => ConnectionStateChanged?.Invoke(this, args);
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// No-op for testing
|
||||
}
|
||||
}
|
||||
|
||||
// Methods to raise events from tests
|
||||
public void RaiseDataChanged(DataChangedEventArgs args)
|
||||
{
|
||||
DataChanged?.Invoke(this, args);
|
||||
}
|
||||
|
||||
public void RaiseAlarmEvent(AlarmEventArgs args)
|
||||
{
|
||||
AlarmEvent?.Invoke(this, args);
|
||||
}
|
||||
|
||||
public void RaiseConnectionStateChanged(ConnectionStateChangedEventArgs args)
|
||||
{
|
||||
ConnectionStateChanged?.Invoke(this, args);
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ using ZB.MOM.WW.LmxOpcUa.Client.Shared;
|
||||
namespace ZB.MOM.WW.LmxOpcUa.Client.UI.Tests.Fakes;
|
||||
|
||||
/// <summary>
|
||||
/// Fake factory that returns a preconfigured FakeOpcUaClientService.
|
||||
/// Fake factory that returns a preconfigured FakeOpcUaClientService.
|
||||
/// </summary>
|
||||
public sealed class FakeOpcUaClientServiceFactory : IOpcUaClientServiceFactory
|
||||
{
|
||||
@@ -14,5 +14,8 @@ public sealed class FakeOpcUaClientServiceFactory : IOpcUaClientServiceFactory
|
||||
_service = service;
|
||||
}
|
||||
|
||||
public IOpcUaClientService Create() => _service;
|
||||
}
|
||||
public IOpcUaClientService Create()
|
||||
{
|
||||
return _service;
|
||||
}
|
||||
}
|
||||
@@ -17,15 +17,15 @@ public class HistoryViewModelTests
|
||||
{
|
||||
_service = new FakeOpcUaClientService
|
||||
{
|
||||
HistoryRawResult = new[]
|
||||
{
|
||||
HistoryRawResult =
|
||||
[
|
||||
new DataValue(new Variant(10), StatusCodes.Good, DateTime.UtcNow, DateTime.UtcNow),
|
||||
new DataValue(new Variant(20), StatusCodes.Good, DateTime.UtcNow, DateTime.UtcNow)
|
||||
},
|
||||
HistoryAggregateResult = new[]
|
||||
{
|
||||
],
|
||||
HistoryAggregateResult =
|
||||
[
|
||||
new DataValue(new Variant(15.0), StatusCodes.Good, DateTime.UtcNow, DateTime.UtcNow)
|
||||
}
|
||||
]
|
||||
};
|
||||
var dispatcher = new SynchronousUiDispatcher();
|
||||
_vm = new HistoryViewModel(_service, dispatcher);
|
||||
@@ -157,4 +157,4 @@ public class HistoryViewModelTests
|
||||
_vm.Results.Count.ShouldBe(1);
|
||||
_vm.Results[0].Value.ShouldContain("History not supported");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,11 +25,11 @@ public class MainWindowViewModelTests
|
||||
"http://opcfoundation.org/UA/SecurityPolicy#None",
|
||||
"session-1",
|
||||
"TestSession"),
|
||||
BrowseResults = new[]
|
||||
{
|
||||
BrowseResults =
|
||||
[
|
||||
new BrowseResult("ns=2;s=Root", "Root", "Object", true)
|
||||
},
|
||||
RedundancyResult = new RedundancyInfo("None", 200, new[] { "urn:test" }, "urn:test")
|
||||
],
|
||||
RedundancyResult = new RedundancyInfo("None", 200, ["urn:test"], "urn:test")
|
||||
};
|
||||
|
||||
var factory = new FakeOpcUaClientServiceFactory(_service);
|
||||
@@ -123,7 +123,8 @@ public class MainWindowViewModelTests
|
||||
public void ConnectionStateChangedEvent_UpdatesState()
|
||||
{
|
||||
_service.RaiseConnectionStateChanged(
|
||||
new ConnectionStateChangedEventArgs(ConnectionState.Disconnected, ConnectionState.Reconnecting, "opc.tcp://localhost:4840"));
|
||||
new ConnectionStateChangedEventArgs(ConnectionState.Disconnected, ConnectionState.Reconnecting,
|
||||
"opc.tcp://localhost:4840"));
|
||||
|
||||
_vm.ConnectionState.ShouldBe(ConnectionState.Reconnecting);
|
||||
_vm.StatusMessage.ShouldBe("Reconnecting...");
|
||||
@@ -182,7 +183,8 @@ public class MainWindowViewModelTests
|
||||
_vm.PropertyChanged += (_, e) => changed.Add(e.PropertyName!);
|
||||
|
||||
_service.RaiseConnectionStateChanged(
|
||||
new ConnectionStateChangedEventArgs(ConnectionState.Disconnected, ConnectionState.Connected, "opc.tcp://localhost:4840"));
|
||||
new ConnectionStateChangedEventArgs(ConnectionState.Disconnected, ConnectionState.Connected,
|
||||
"opc.tcp://localhost:4840"));
|
||||
|
||||
changed.ShouldContain(nameof(MainWindowViewModel.ConnectionState));
|
||||
changed.ShouldContain(nameof(MainWindowViewModel.IsConnected));
|
||||
@@ -325,4 +327,4 @@ public class MainWindowViewModelTests
|
||||
|
||||
_vm.IsHistoryEnabledForSelection.ShouldBeFalse();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -149,4 +149,4 @@ public class ReadWriteViewModelTests
|
||||
_vm.SelectedNodeId = null;
|
||||
_vm.IsNodeSelected.ShouldBeFalse();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -168,4 +168,4 @@ public class SubscriptionsViewModelTests
|
||||
_vm.ActiveSubscriptions.ShouldBeEmpty();
|
||||
_service.SubscribeCallCount.ShouldBe(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,27 +1,27 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<IsPackable>false</IsPackable>
|
||||
<IsTestProject>true</IsTestProject>
|
||||
<RootNamespace>ZB.MOM.WW.LmxOpcUa.Client.UI.Tests</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<IsPackable>false</IsPackable>
|
||||
<IsTestProject>true</IsTestProject>
|
||||
<RootNamespace>ZB.MOM.WW.LmxOpcUa.Client.UI.Tests</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="xunit.v3" Version="1.1.0" />
|
||||
<PackageReference Include="Shouldly" Version="4.3.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.2">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="xunit.v3" Version="1.1.0"/>
|
||||
<PackageReference Include="Shouldly" Version="4.3.0"/>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0"/>
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.2">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\ZB.MOM.WW.LmxOpcUa.Client.UI\ZB.MOM.WW.LmxOpcUa.Client.UI.csproj" />
|
||||
<ProjectReference Include="..\..\src\ZB.MOM.WW.LmxOpcUa.Client.Shared\ZB.MOM.WW.LmxOpcUa.Client.Shared.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\ZB.MOM.WW.LmxOpcUa.Client.UI\ZB.MOM.WW.LmxOpcUa.Client.UI.csproj"/>
|
||||
<ProjectReference Include="..\..\src\ZB.MOM.WW.LmxOpcUa.Client.Shared\ZB.MOM.WW.LmxOpcUa.Client.Shared.csproj"/>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user