Write() public method

public Write ( byte data ) : void
data byte
return void
Example #1
0
        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();
        }
Example #2
0
        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();
        }
Example #3
0
 public void ThrowsExceptionTryingToWriteBytesOnClosed()
 {
     Session session = new Session("localhost", DefaultPort);
     server.AcceptTcpClient().Close();
     Assert.Throws<SocketException>(() => session.Write(new byte[] { 0xCA }));
 }