public void CanSendByte() { byte expected = 0xCA; Session session = new Session("localhost", DefaultPort); session.Write(expected); TcpClient client = server.AcceptTcpClient(); int actual = client.GetStream().ReadByte(); Assert.AreEqual(expected, actual); client.Close(); session.Close(); }
public void CanSendBytes() { byte[] expected = new byte[] { 0xCA, 0xFE }; Session session = new Session("localhost", DefaultPort); session.Write(expected); TcpClient client = server.AcceptTcpClient(); byte[] actual = new byte[2]; client.GetStream().Read(actual, 0, 2); Assert.AreEqual(expected, actual); client.Close(); session.Close(); }
public void ThrowsExceptionTryingToWriteBytesOnClosed() { Session session = new Session("localhost", DefaultPort); server.AcceptTcpClient().Close(); Assert.Throws<SocketException>(() => session.Write(new byte[] { 0xCA })); }