Beispiel #1
0
            public void Sending_packet_with_byte_array_should_call_raw_client_with_header_appended()
            {
                var c = new FramedClient(rawClient.Object);

                c.SendPacket(new byte[] { 1, 2, 3 });

                rawClient.Verify(r => r.Send(new byte[] { 7, 0, 0, 0, 1, 2, 3 }));
            }
Beispiel #2
0
            public void Sending_preformatted_packet_should_not_add_additional_header()
            {
                var c = new FramedClient(rawClient.Object);
                var data = new byte[] { 1, 2, 3, 4, 5, 6, 7 };

                var buffer = c.PreparePacketBuffer(7);
                Buffer.BlockCopy(data, 0, buffer.Packet.Array, buffer.Packet.Offset, data.Length);

                c.SendPacket(buffer);

                rawClient.Verify(r => r.Send(new byte[] { 11, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7 }));
                Assert.Equal(11, buffer.Packet.Array.Length);
                Assert.Equal(7, buffer.Packet.Count);
            }
Beispiel #3
0
            public void Sending_packet_with_array_segment_should_call_raw_client_with_header_appended()
            {
                var c = new FramedClient(rawClient.Object);

                c.SendPacket(new ArraySegment<byte>(new byte[] { 0, 0, 5, 0, 0, 0, 54, 1, 2, 3 }, 6, 1));

                rawClient.Verify(r => r.Send(new byte[] { 5, 0, 0, 0, 54 }));
            }