예제 #1
0
        public void BinaryWriterUtility_WriteNullableArrayT_1()
        {
            Dummy[] expected = new Dummy[10];
            for (int i = 0; i < expected.Length; i++)
            {
                expected[i] = new Dummy {
                    Value = i
                };
            }

            MemoryStream stream = new MemoryStream();
            BinaryWriter writer = new BinaryWriter(stream);

            BinaryWriterUtility.WriteNullableArray(writer, expected);

            byte[] bytes = stream.ToArray();
            stream = new MemoryStream(bytes);
            BinaryReader reader = new BinaryReader(stream);

            Dummy[] actual = BinaryReaderUtility.ReadNullableArray <Dummy>(reader);
            Assert.IsNotNull(actual);
            Assert.AreEqual(expected.Length, actual.Length);
            for (int i = 0; i < expected.Length; i++)
            {
                Dummy item1 = expected[i];
                Dummy item2 = actual[i];
                Assert.AreEqual(item1.Value, item2.Value);
            }
        }
예제 #2
0
        public void BinaryWriterUtility_WriteNullableArray_String_1()
        {
            string[] expected = new string[10];
            for (int i = 0; i < expected.Length; i++)
            {
                expected[i] = "Item" + i;
            }

            MemoryStream stream = new MemoryStream();
            BinaryWriter writer = new BinaryWriter(stream);

            BinaryWriterUtility.WriteNullableArray(writer, expected);

            byte[] bytes = stream.ToArray();
            stream = new MemoryStream(bytes);
            BinaryReader reader = new BinaryReader(stream);

            string[] actual = BinaryReaderUtility.ReadNullableStringArray(reader);
            Assert.IsNotNull(actual);
            Assert.AreEqual(expected.Length, actual.Length);
            for (int i = 0; i < expected.Length; i++)
            {
                Assert.AreEqual(expected[i], actual[i]);
            }
        }
예제 #3
0
        public void BinaryWriterUtility_WriteNullableArrayT_2()
        {
            Dummy[] expected = null;

            MemoryStream stream = new MemoryStream();
            BinaryWriter writer = new BinaryWriter(stream);

            BinaryWriterUtility.WriteNullableArray(writer, expected);

            byte[] bytes = stream.ToArray();
            stream = new MemoryStream(bytes);
            BinaryReader reader = new BinaryReader(stream);

            Dummy[] actual = BinaryReaderUtility.ReadNullableArray <Dummy>(reader);
            Assert.IsNull(actual);
        }