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:
@@ -8,57 +8,24 @@ using ZB.MOM.WW.LmxOpcUa.Host.Domain;
|
||||
namespace ZB.MOM.WW.LmxOpcUa.Tests.Helpers
|
||||
{
|
||||
/// <summary>
|
||||
/// xUnit fixture that manages an OpcUaService lifecycle with automatic port allocation.
|
||||
/// Guarantees no port conflicts between parallel tests.
|
||||
///
|
||||
/// Usage (per-test):
|
||||
/// var fixture = OpcUaServerFixture.WithFakes();
|
||||
/// await fixture.InitializeAsync();
|
||||
/// try { ... } finally { await fixture.DisposeAsync(); }
|
||||
///
|
||||
/// Usage (skip COM entirely):
|
||||
/// var fixture = OpcUaServerFixture.WithFakeMxAccessClient();
|
||||
/// xUnit fixture that manages an OpcUaService lifecycle with automatic port allocation.
|
||||
/// Guarantees no port conflicts between parallel tests.
|
||||
/// Usage (per-test):
|
||||
/// var fixture = OpcUaServerFixture.WithFakes();
|
||||
/// await fixture.InitializeAsync();
|
||||
/// try { ... } finally { await fixture.DisposeAsync(); }
|
||||
/// Usage (skip COM entirely):
|
||||
/// var fixture = OpcUaServerFixture.WithFakeMxAccessClient();
|
||||
/// </summary>
|
||||
internal class OpcUaServerFixture : IAsyncLifetime
|
||||
{
|
||||
private static int _nextPort = 16000;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the started service instance managed by the fixture.
|
||||
/// </summary>
|
||||
public OpcUaService Service { get; private set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the OPC UA port assigned to this fixture instance.
|
||||
/// </summary>
|
||||
public int OpcUaPort { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the OPC UA endpoint URL exposed by the fixture.
|
||||
/// </summary>
|
||||
public string EndpointUrl => $"opc.tcp://localhost:{OpcUaPort}/LmxOpcUa";
|
||||
|
||||
/// <summary>
|
||||
/// The fake Galaxy repository injected into the service. Mutate Hierarchy/Attributes
|
||||
/// then call Service.TriggerRebuild() to simulate a Galaxy redeployment.
|
||||
/// </summary>
|
||||
public FakeGalaxyRepository? GalaxyRepository { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The fake MxAccess client injected into the service (when using WithFakeMxAccessClient).
|
||||
/// </summary>
|
||||
public FakeMxAccessClient? MxAccessClient { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The fake MxProxy injected into the service (when using WithFakes).
|
||||
/// </summary>
|
||||
public FakeMxProxy? MxProxy { get; }
|
||||
|
||||
private readonly OpcUaServiceBuilder _builder;
|
||||
private bool _started;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a fixture around a prepared service builder and optional fake dependencies.
|
||||
/// Initializes a fixture around a prepared service builder and optional fake dependencies.
|
||||
/// </summary>
|
||||
/// <param name="builder">The builder used to construct the service under test.</param>
|
||||
/// <param name="repo">The optional fake Galaxy repository exposed to tests.</param>
|
||||
@@ -79,8 +46,68 @@ namespace ZB.MOM.WW.LmxOpcUa.Tests.Helpers
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates fixture with FakeMxProxy + FakeGalaxyRepository (standard test data).
|
||||
/// The STA thread and COM interop run against FakeMxProxy.
|
||||
/// Gets the started service instance managed by the fixture.
|
||||
/// </summary>
|
||||
public OpcUaService Service { get; private set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the OPC UA port assigned to this fixture instance.
|
||||
/// </summary>
|
||||
public int OpcUaPort { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the OPC UA endpoint URL exposed by the fixture.
|
||||
/// </summary>
|
||||
public string EndpointUrl => $"opc.tcp://localhost:{OpcUaPort}/LmxOpcUa";
|
||||
|
||||
/// <summary>
|
||||
/// The fake Galaxy repository injected into the service. Mutate Hierarchy/Attributes
|
||||
/// then call Service.TriggerRebuild() to simulate a Galaxy redeployment.
|
||||
/// </summary>
|
||||
public FakeGalaxyRepository? GalaxyRepository { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The fake MxAccess client injected into the service (when using WithFakeMxAccessClient).
|
||||
/// </summary>
|
||||
public FakeMxAccessClient? MxAccessClient { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The fake MxProxy injected into the service (when using WithFakes).
|
||||
/// </summary>
|
||||
public FakeMxProxy? MxProxy { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Builds and starts the OPC UA service for the current fixture.
|
||||
/// </summary>
|
||||
public Task InitializeAsync()
|
||||
{
|
||||
Service = _builder.Build();
|
||||
Service.Start();
|
||||
_started = true;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stops the OPC UA service when the fixture had previously been started.
|
||||
/// </summary>
|
||||
public Task DisposeAsync()
|
||||
{
|
||||
if (_started)
|
||||
try
|
||||
{
|
||||
Service.Stop();
|
||||
}
|
||||
catch
|
||||
{
|
||||
/* swallow cleanup errors */
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates fixture with FakeMxProxy + FakeGalaxyRepository (standard test data).
|
||||
/// The STA thread and COM interop run against FakeMxProxy.
|
||||
/// </summary>
|
||||
/// <param name="proxy">An optional fake proxy to inject; otherwise a default fake is created.</param>
|
||||
/// <param name="repo">An optional fake repository to inject; otherwise standard test data is used.</param>
|
||||
@@ -101,12 +128,12 @@ namespace ZB.MOM.WW.LmxOpcUa.Tests.Helpers
|
||||
.WithGalaxyRepository(r)
|
||||
.WithGalaxyName("TestGalaxy");
|
||||
|
||||
return new OpcUaServerFixture(builder, repo: r, mxProxy: p);
|
||||
return new OpcUaServerFixture(builder, r, mxProxy: p);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates fixture using FakeMxAccessClient directly — skips STA thread + COM entirely.
|
||||
/// Fastest option for tests that don't need real COM interop.
|
||||
/// Creates fixture using FakeMxAccessClient directly — skips STA thread + COM entirely.
|
||||
/// Fastest option for tests that don't need real COM interop.
|
||||
/// </summary>
|
||||
/// <param name="mxClient">An optional fake MXAccess client to inject; otherwise a default fake is created.</param>
|
||||
/// <param name="repo">An optional fake repository to inject; otherwise standard test data is used.</param>
|
||||
@@ -150,31 +177,7 @@ namespace ZB.MOM.WW.LmxOpcUa.Tests.Helpers
|
||||
if (authProvider != null)
|
||||
builder.WithAuthProvider(authProvider);
|
||||
|
||||
return new OpcUaServerFixture(builder, repo: r, mxClient: client);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Builds and starts the OPC UA service for the current fixture.
|
||||
/// </summary>
|
||||
public Task InitializeAsync()
|
||||
{
|
||||
Service = _builder.Build();
|
||||
Service.Start();
|
||||
_started = true;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stops the OPC UA service when the fixture had previously been started.
|
||||
/// </summary>
|
||||
public Task DisposeAsync()
|
||||
{
|
||||
if (_started)
|
||||
{
|
||||
try { Service.Stop(); }
|
||||
catch { /* swallow cleanup errors */ }
|
||||
}
|
||||
return Task.CompletedTask;
|
||||
return new OpcUaServerFixture(builder, r, client);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user