public void Send_AllInOrder_CorrectOrder() { var loopback = new Loopback(LoopbackTypes.AllInOrder); var lhs = new UnreliableOrderedConnection(loopback.RhsUpdSend, 1, new NullTrace()); var rhs = new UnreliableOrderedConnection(loopback.LhsUdpSend, 1, new NullTrace()); loopback.RhsUpdSend.Sink = rhs; loopback.LhsUdpSend.Sink = lhs; var list = new List <Paket>(); rhs.NewPaket += (p1, p2) => { list.Add(p2); }; for (int i = 0; i < 100000; i++) { var paket = lhs.CreatePaket(); SimpleTypeWriter.Write(i + "Test" + i, paket); SimpleTypeWriter.Write(i, paket); lhs.Send(paket); } Assert.Equal(100000, list.Count); for (int i = 0; i < list.Count; i++) { var paket = list[i]; var message = SimpleTypeReader.ReadString(paket); var number = SimpleTypeReader.ReadInt(paket); Assert.Equal(i, number); Assert.Equal(message, i + "Test" + i); } }
public void WriteReadInt_12345678() { var paket = new Paket(); paket.Offset = 5; SimpleTypeWriter.Write(12345678, paket); paket.Offset = 5; Assert.Equal(12345678, SimpleTypeReader.ReadInt(paket)); }
public void WriteReadInt_1() { var paket = new Paket(); paket.Offset = 8; SimpleTypeWriter.Write(1, paket); paket.Offset = 8; Assert.Equal(1, SimpleTypeReader.ReadInt(paket)); }
public void Float() { for (float i = -1000000; i < 1000000; i += 1.37f) { var paket = new Paket(); paket.Offset = 7; SimpleTypeWriter.Write(i, paket); paket.Offset = 7; Assert.Equal(i, SimpleTypeReader.ReadFloat(paket)); } }
public void UInt() { uint prev = 0; for (uint i = 0; prev <= i; i += 29787) { prev = i; var paket = new Paket(); paket.Offset = 7; SimpleTypeWriter.Write(i, paket); paket.Offset = 7; Assert.Equal(i, SimpleTypeReader.ReadUInt(paket)); } }
private void SetUid(Paket paket) { paket.Offset = 8; paket.Uid = GetUid(); SimpleTypeWriter.Write((int)paket.Uid, paket); }
public void Serialize(Paket paket) { SimpleTypeWriter.Write(TestString, paket); SimpleTypeWriter.Write(TestNumber, paket); }
public void Serialize(Paket paket) { SimpleTypeWriter.Write(ClientVersion, paket); }
public void Serialize(Paket paket) { SimpleTypeWriter.Write(ServerName, paket); SimpleTypeWriter.Write(ServerVersion, paket); SimpleTypeWriter.Write(RunningId, paket); }