示例#1
0
        public void TestArrays()
        {
            var outByteArray = new byte[]
            {
                1,
                2,
                13,
                37,
                69
            };
            var outIntArray = new int[]
            {
                1337,
                69420,
                12345,
                0,
                0,
                5
            };
            var outDoubleArray = new double[]
            {
                0.02,
                0.06,
                1E40,
                256.0
            };

            var outNetworkBuffer = new NetworkBuffer();
            var outNetworkWriter = new NetworkWriter(outNetworkBuffer);

            outNetworkWriter.WriteByteArray(outByteArray);
            outNetworkWriter.WriteIntArray(outIntArray);
            outNetworkWriter.WriteDoubleArray(outDoubleArray);

            var inNetworkBuffer = new NetworkBuffer(outNetworkBuffer.GetBuffer());
            var inNetworkReader = new NetworkReader(inNetworkBuffer);
            var inByteArray     = inNetworkReader.ReadByteArray();
            var inIntArray      = inNetworkReader.ReadIntArray();
            var inDoubleArray   = inNetworkReader.ReadDoubleArray();

            Assert.That(outByteArray, Is.EqualTo(inByteArray));
            Assert.That(outIntArray, Is.EqualTo(inIntArray));
            Assert.That(outDoubleArray, Is.EqualTo(inDoubleArray));
        }