deprecate(lmxproxy): move all LmxProxy code, tests, and docs to deprecated/
LmxProxy is no longer needed. Moved the entire lmxproxy/ workspace, DCL adapter files, and related docs to deprecated/. Removed LmxProxy registration from DataConnectionFactory, project reference from DCL, protocol option from UI, and cleaned up all requirement docs.
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
using FluentAssertions;
|
||||
using Xunit;
|
||||
using ZB.MOM.WW.LmxProxy.Client.Domain;
|
||||
using ZB.MOM.WW.LmxProxy.Client.Tests.Fakes;
|
||||
|
||||
namespace ZB.MOM.WW.LmxProxy.Client.Tests;
|
||||
|
||||
public class LmxProxyClientConnectionTests
|
||||
{
|
||||
[Fact]
|
||||
public async Task IsConnectedAsync_ReturnsFalseBeforeConnect()
|
||||
{
|
||||
var client = new LmxProxyClient("localhost", 50051, null, null);
|
||||
|
||||
var result = await client.IsConnectedAsync();
|
||||
|
||||
result.Should().BeFalse();
|
||||
client.Dispose();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task IsConnectedAsync_ReturnsTrueAfterInjection()
|
||||
{
|
||||
var (client, _) = TestableClient.CreateConnected();
|
||||
|
||||
var result = await client.IsConnectedAsync();
|
||||
|
||||
result.Should().BeTrue();
|
||||
client.Dispose();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task DisconnectAsync_SendsDisconnectAndClearsState()
|
||||
{
|
||||
var (client, fake) = TestableClient.CreateConnected();
|
||||
|
||||
await client.DisconnectAsync();
|
||||
|
||||
fake.DisconnectCalls.Should().HaveCount(1);
|
||||
fake.DisconnectCalls[0].SessionId.Should().Be("test-session-123");
|
||||
client.IsConnected.Should().BeFalse();
|
||||
client.Dispose();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task DisconnectAsync_SwallowsExceptions()
|
||||
{
|
||||
var (client, fake) = TestableClient.CreateConnected();
|
||||
fake.DisconnectResponseToReturn = null!; // Force an error path
|
||||
|
||||
// Should not throw
|
||||
var act = () => client.DisconnectAsync();
|
||||
await act.Should().NotThrowAsync();
|
||||
|
||||
client.Dispose();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IsConnected_ReturnsFalseAfterDispose()
|
||||
{
|
||||
var (client, _) = TestableClient.CreateConnected();
|
||||
|
||||
client.Dispose();
|
||||
|
||||
client.IsConnected.Should().BeFalse();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task MarkDisconnectedAsync_ClearsConnectionState()
|
||||
{
|
||||
var (client, _) = TestableClient.CreateConnected();
|
||||
|
||||
await client.MarkDisconnectedAsync(new Exception("connection lost"));
|
||||
|
||||
client.IsConnected.Should().BeFalse();
|
||||
client.Dispose();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DefaultTimeout_RejectsOutOfRange()
|
||||
{
|
||||
var client = new LmxProxyClient("localhost", 50051, null, null);
|
||||
|
||||
var act = () => client.DefaultTimeout = TimeSpan.FromMilliseconds(500);
|
||||
act.Should().Throw<ArgumentOutOfRangeException>();
|
||||
|
||||
var act2 = () => client.DefaultTimeout = TimeSpan.FromMinutes(11);
|
||||
act2.Should().Throw<ArgumentOutOfRangeException>();
|
||||
|
||||
client.Dispose();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DefaultTimeout_AcceptsValidRange()
|
||||
{
|
||||
var client = new LmxProxyClient("localhost", 50051, null, null);
|
||||
|
||||
client.DefaultTimeout = TimeSpan.FromSeconds(5);
|
||||
client.DefaultTimeout.Should().Be(TimeSpan.FromSeconds(5));
|
||||
|
||||
client.Dispose();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user