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]); } }
public void BinaryWriterUtility_WriteNullableArray_String_2() { string[] 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); string[] actual = BinaryReaderUtility.ReadNullableStringArray(reader); Assert.IsNull(actual); }