public void Server開始後に接続後にDataReceiveでStartControl() { using (var server = new AwaitingServer()) { Assert.AreEqual(false, server.IsConnected); Assert.AreEqual(false, server.IsListening); Assert.AreEqual(false, server.IsNetworkConnected); server.StartNetwork(9999); Thread.Sleep(100); Assert.AreEqual(false, server.IsConnected); Assert.AreEqual(true, server.IsListening); Assert.AreEqual(false, server.IsNetworkConnected); server.RequestControl += (s, e) => { server.StartControl("D2XX0"); }; var client = new TcpClient(); client.Connect(IPAddress.Loopback, 9999); var ns = client.GetStream(); CheckIo(ns); Assert.AreEqual(true, server.IsConnected); Assert.AreEqual(false, server.IsListening); Assert.AreEqual(true, server.IsNetworkConnected); ns.Dispose(); server.StopControl(); Assert.AreEqual(false, server.IsConnected); Assert.AreEqual(false, server.IsListening); Assert.AreEqual(true, server.IsNetworkConnected); } }
public void ListenAccept中に停止() { using (var server = new AwaitingServer()) { Assert.AreEqual(false, server.IsConnected); Assert.AreEqual(false, server.IsListening); Assert.AreEqual(false, server.IsNetworkConnected); server.StartNetwork(9999); Thread.Sleep(100); Assert.AreEqual(false, server.IsConnected); Assert.AreEqual(true, server.IsListening); Assert.AreEqual(false, server.IsNetworkConnected); server.StopNetwork(); Assert.AreEqual(false, server.IsConnected); Assert.AreEqual(false, server.IsListening); Assert.AreEqual(false, server.IsNetworkConnected); } }
public void StopControl後に停止() { using (var server = new AwaitingServer()) { Assert.AreEqual(false, server.IsConnected); Assert.AreEqual(false, server.IsListening); Assert.AreEqual(false, server.IsNetworkConnected); server.StartNetwork(9999); Thread.Sleep(100); Assert.AreEqual(false, server.IsConnected); Assert.AreEqual(true, server.IsListening); Assert.AreEqual(false, server.IsNetworkConnected); using (var client = new TcpClient()) { client.Connect(IPAddress.Loopback, 9999); Thread.Sleep(100); Assert.AreEqual(false, server.IsConnected); Assert.AreEqual(false, server.IsListening); Assert.AreEqual(true, server.IsNetworkConnected); server.StartControl("D2XX0"); CheckIo(client.GetStream()); Assert.AreEqual(true, server.IsConnected); Assert.AreEqual(false, server.IsListening); Assert.AreEqual(true, server.IsNetworkConnected); server.StopControl(); Assert.AreEqual(false, server.IsConnected); Assert.AreEqual(false, server.IsListening); Assert.AreEqual(true, server.IsNetworkConnected); server.StopNetwork(); Assert.AreEqual(false, server.IsConnected); Assert.AreEqual(false, server.IsListening); Assert.AreEqual(false, server.IsNetworkConnected); } } }
public void データ待ち中に停止() { using (var server = new AwaitingServer()) { Assert.AreEqual(false, server.IsConnected); Assert.AreEqual(false, server.IsListening); Assert.AreEqual(false, server.IsNetworkConnected); server.StartNetwork(9999); Thread.Sleep(100); Assert.AreEqual(false, server.IsConnected); Assert.AreEqual(true, server.IsListening); Assert.AreEqual(false, server.IsNetworkConnected); using (var client = new TcpClient()) { client.Connect(IPAddress.Loopback, 9999); Thread.Sleep(100); Assert.AreEqual(false, server.IsConnected); Assert.AreEqual(false, server.IsListening); Assert.AreEqual(true, server.IsNetworkConnected); server.StopNetwork(); Assert.AreEqual(false, server.IsConnected); Assert.AreEqual(false, server.IsListening); Assert.AreEqual(false, server.IsNetworkConnected); } } }