public void TestNullBridgeStream() { BridgeStream stream = null; _sendBridgeStream.Write(stream); var data = _sendBridgeStream.Encode(); var receivePacket = new BridgeStream(data); var sendValue = receivePacket.ReadStream(); Assert.IsTrue(sendValue.Empty); }
public void TestPacket() { var a = new BridgeStream(); a.Write("Ferhat"); a.Write(10); a.Write(true); a.Write((byte)255); a.Write(15f); _sendBridgeStream.Write(a); var b = new BridgeStream(); b.Write("Mehmet"); b.Write(15); b.Write(35f); _sendBridgeStream.Write(b); var data = _sendBridgeStream.Encode(); var receivePacket = new BridgeStream(data); var readPacketA = receivePacket.ReadStream(); var readPacketB = receivePacket.ReadStream(); Assert.AreEqual("Ferhat", readPacketA.ReadString(), "Expected to get the same string as the first read on the received packet"); Assert.AreEqual(10, readPacketA.ReadInt(), "Expected to get the same integer as the second read on the received packet"); Assert.AreEqual(true, readPacketA.ReadBool(), "Expected to get the same bool as the second read on the received packet"); Assert.AreEqual((byte)255, readPacketA.ReadByte(), "Expected to get the same byte as the third read on the received packet"); Assert.AreEqual("Mehmet", readPacketB.ReadString(), "Expected to get the same string as the first read on the received packet"); Assert.AreEqual(15, readPacketB.ReadInt(), "Expected to get the same integer as the second read on the received packet"); Assert.AreEqual(35f, readPacketB.ReadFloat(), "Expected to get the same float as the third read on the received packet"); }