Beispiel #1
0
        public void ReadBooleanFromStream(byte[] value, bool expected)
        {
            var streamMock = new MemoryStream(value);
            var packet     = new PacketMock();

            var result = packet.TestReadBooleanFromStream(new PacketReader(), streamMock);

            result.Should().Be(expected);
        }
Beispiel #2
0
        public void ReadGuidFromStream()
        {
            var streamMock = new MemoryStream(new byte[16] {
                98, 111, 189, 219, 189, 110, 44, 70, 168, 8, 141, 230, 172, 68, 49, 58
            });
            var packet = new PacketMock();

            var result = packet.TestReadGuidFromStream(new PacketReader(), streamMock);

            result.Should().Be(Guid.Parse("dbbd6f62-6ebd-462c-a808-8de6ac44313a"));
        }
Beispiel #3
0
        public void ReadEmptyStringWontThrow()
        {
            var streamMock = new MemoryStream(new byte[4] {
                0, 0, 0, 0
            });
            var packet = new PacketMock();

            var result = packet.TestReadStringFromStream(new PacketReader(), streamMock);

            result.Should().Be(string.Empty);
        }
Beispiel #4
0
        public void ReadStringFromStream()
        {
            var streamMock = new MemoryStream(new byte[28] {
                0, 0, 0, 24, 84, 104, 105, 115, 32, 105, 115, 32, 97,
                110, 32, 97, 119, 101, 115, 111, 109, 101, 32, 116, 101, 115, 116, 33
            });
            var packet = new PacketMock();

            var result = packet.TestReadStringFromStream(new PacketReader(), streamMock);

            result.Should().Be("This is an awesome test!");
        }
Beispiel #5
0
        static async Task Main(string[] args)
        {
            var client = new ClientNetworkManagerTcp(new NegumSideMock(), ConnectionContextMock.LocalHost);
            await client.ConnectAsync();

            var packetsToSend = 2;

            for (var i = 0; i < packetsToSend; ++i)
            {
                var packet = new PacketMock();
                await client.SendAsync(packet);
            }

            await client.DisconnectAsync();
        }