Esempio n. 1
0
        public void WriteIntValueTest()
        {
            const int testValue = 2020;

            Assert.AreEqual(0, binaryWriter.Written);
            Assert.AreEqual(0, binaryWriter.GetWrittenBuffer().Length);

            binaryWriter.WriteValue(testValue);
            Assert.AreEqual(sizeof(int), binaryWriter.Written);
            Assert.AreEqual(sizeof(int), binaryWriter.GetWrittenBuffer().Length);
            Assert.IsTrue(BitConverter.GetBytes(testValue).AsSpan().SequenceEqual(binaryWriter.GetWrittenBuffer().Span));
        }
Esempio n. 2
0
        public void TryReadFrom_DoesNotReadSentTimeWhenFlagIsNotSet()
        {
            var packetWriter = new ENetPacketWriter();

            packetWriter.WriteValue <ushort>(0);
            packetWriter.WriteValue <ushort>(0);

            var packetReader = new ENetPacketReader(packetWriter.GetWrittenBuffer().Span);

            Assert.IsTrue(ENetProtocolHeader.TryReadFrom(ref packetReader, out var header));
            Assert.AreEqual(2, packetReader.Left.Length);
        }