public void BinaryWriterUtility_WriteNullableArray_Int32_1() { int[] expected = new int[10]; for (int i = 0; i < expected.Length; i++) { expected[i] = 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); int[] actual = BinaryReaderUtility.ReadNullableInt32Array(reader); Assert.IsNotNull(actual); Assert.AreEqual(expected.Length, actual.Length); for (int i = 0; i < expected.Length; i++) { Assert.AreEqual(expected[i], actual[i]); } }
public void BinaryWriterUtility_WriteNullableArray_Int32_2() { int[] 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); int[] actual = BinaryReaderUtility.ReadNullableInt32Array(reader); Assert.IsNull(actual); }