public void PacketStreamWriteWhenReadOnlyTest() { using (ILitePacketStream packetStream = new LitePacketStream(_randomizer.Bytes(_randomizer.Byte()))) { Assert.Throws <InvalidOperationException>(() => packetStream.Write <byte>(_randomizer.Byte())); } }
public void PacketStreamReadNonPrimitiveTest() { using (var packetStream = new NetPacketStream(_randomizer.Bytes(_randomizer.Byte()))) { Assert.Throws <NotImplementedException>(() => packetStream.Read <object>()); } }
public NetServerClientTests() { _randomizer = new Randomizer((int)DateTime.UtcNow.Ticks); _serverConfiguration = new NetServerConfiguration("127.0.0.1", 4444); _serverMock = new NetServerMock <CustomClient>(_serverConfiguration); _customClient = new CustomClient(null) { Server = _serverMock.Object }; _otherClient = new CustomClient(null); _customClientsList = Enumerable.Repeat(new CustomClient(null), _randomizer.Byte()); _packet = new NetPacket(); _packet.Write(_randomizer.String(_randomizer.Byte())); }
public async Task SendPacketTest() { byte[] message = _randomizer.Bytes(_randomizer.Byte()); _clientMock.SocketMock.ConfigureSendResult(false); // Instant send _sender.Start(); _sender.Send(new NetMessageData(_clientMock.Object, message)); // Wait 1 second so the sender task can process the previous message. await Task.Delay(1000).ConfigureAwait(false); _clientMock.SocketMock.VerifySend(It.IsAny <SocketAsyncEventArgs>(), Times.Once()); _sender.Stop(); Assert.False(_sender.IsRunning); }
public void generate_a_byte() { r.Byte(1, 128).Should().Be(78); }
public void Byte_range_is_inclusive() { CanReturn(() => _randomizer.Byte(byte.MaxValue - 10, byte.MaxValue), byte.MaxValue); CanReturn(() => _randomizer.Byte(byte.MinValue, byte.MinValue + 10), byte.MinValue); }