public void Enum_BitStreamerUsingUnderlyingTypeTest() { const int k_bit_count = 32; using (var ms = new System.IO.MemoryStream()) using (var s = new IO.BitStream(ms)) { const EnumBinaryStreamerTest.UInt32Enum kExpectedValue = EnumBinaryStreamerTest.UInt32Enum.DeadBeef; var value = kExpectedValue; s.StreamMode = System.IO.FileAccess.Write; UInt32EnumStreamer.Write(s, value, k_bit_count); s.Flush(); s.SeekToStart(); s.StreamMode = System.IO.FileAccess.Read; UInt32EnumStreamer.Read(s, out value, k_bit_count); Assert.AreEqual(kExpectedValue, value); ////////////////////////////////////////////////////////////////////////// // Test the instance interface var streamer_instance = UInt32EnumStreamer.Instance; s.SeekToStart(); s.StreamMode = System.IO.FileAccess.Write; streamer_instance.Write(s, value, k_bit_count); s.Flush(); s.SeekToStart(); s.StreamMode = System.IO.FileAccess.Read; streamer_instance.Read(s, out value, k_bit_count); Assert.AreEqual(kExpectedValue, value); } }
public void Enum_BinaryStreamerUsingUnderlyingTypeTest() { using (var ms = new System.IO.MemoryStream()) using (var br = new IO.EndianReader(ms)) using (var bw = new IO.EndianWriter(ms)) { const UInt32Enum kExpectedValue = UInt32Enum.DeadBeef; var value = kExpectedValue; UInt32EnumStreamer.Write(bw, value); ms.Position = 0; UInt32EnumStreamer.Read(br, out value); Assert.IsTrue(value == kExpectedValue); ////////////////////////////////////////////////////////////////////////// // Test the instance interface var streamer_instance = UInt32EnumStreamer.Instance; ms.Position = 0; streamer_instance.Write(bw, value); ms.Position = 0; streamer_instance.Read(br, out value); Assert.IsTrue(value == kExpectedValue); } }