private void EnumerableTestMethod <TValue>() { using (var ms = new MemoryStream()) { var arrayValue = TestDataGenerator <TValue> .TestData; ms.WriteValue(arrayValue.Select(value => value)); Assert.IsTrue( ms.ToArray().SequenceEqual(new byte[] { 0xfe, 0xff, 0xff, 0xff, }. Concat(TestDataGenerator <TValue> .TestDataBytesWithFlags))); } using (var ms = new MemoryStream()) { var byteArrayValue = new TValue[0]; ms.WriteValue(byteArrayValue.Select(value => value)); Assert.IsTrue( ms.ToArray().SequenceEqual(new byte[] { 0xfe, 0xff, 0xff, 0xff, 0x00 })); } using (var ms = new MemoryStream()) { ms.WriteValue <IEnumerable <TValue> >(null); Assert.IsTrue( ms.ToArray().SequenceEqual(new byte[] { 0xff, 0xff, 0xff, 0xff, })); } }