public void Test_WhenConnectingOnUsedActiveSocketThenNoConnectionAndRoboDkNotStarted() { var port = 56252; while (!RoboDK.IsTcpPortFree(port)) { port++; } using (var s = new SocketHelper()) { s.OpenServerAndClient(port); RoboDK.IsTcpPortFree(s.ServerPort).Should().BeFalse(); RoboDK.IsTcpPortFree(s.ClientPort).Should().BeFalse(); var rdk = new RoboDK { RoboDKServerStartPort = port, }; rdk.Connect().Should().BeFalse(); rdk.Connected().Should().BeFalse(); rdk.Process.Should().BeNull(); rdk.Connect().Should().BeFalse(); rdk.Connected().Should().BeFalse(); rdk.Process.Should().BeNull(); rdk.Invoking(r => r.CloseRoboDK()) .Should().Throw <RdkException>(); } }
public void Test_WhenStartingOnUsedActiveSocketThenNoConnectionAndRoboDkNotStarted() { var port = 56252; while (!RoboDK.IsTcpPortFree(port)) { port++; } using (var s = new SocketHelper()) { s.OpenServerAndClient(port); RoboDK.IsTcpPortFree(s.ServerPort).Should().BeFalse(); RoboDK.IsTcpPortFree(s.ClientPort).Should().BeFalse(); var rdk = new RoboDK { StartNewInstance = true, RoboDKServerStartPort = port, }; rdk.Connect().Should().BeFalse(); rdk.Connected().Should().BeFalse(); rdk.Process.Should().NotBeNull(); rdk.Process.HasExited.Should().BeTrue(); Process.GetProcessesByName("RoboDK").Should().BeEmpty(); rdk.Connect().Should().BeFalse(); rdk.Connected().Should().BeFalse(); rdk.Process.Should().NotBeNull(); rdk.Process.HasExited.Should().BeTrue(); Process.GetProcessesByName("RoboDK").Should().BeEmpty(); rdk.Invoking(r => r.CloseRoboDK()) .Should().Throw <RdkException>(); } }