public void Enum_BitStreamerDownCastTest() { const int k_bit_count = 8; using (var ms = new System.IO.MemoryStream()) using (var s = new IO.BitStream(ms)) { const System.TypeCode kExpectedValue = System.TypeCode.String; var value = kExpectedValue; s.StreamMode = System.IO.FileAccess.Write; TypeCodeStreamer8.Write(s, value, k_bit_count); s.Flush(); s.SeekToStart(); s.StreamMode = System.IO.FileAccess.Read; TypeCodeStreamer8.Read(s, out value, k_bit_count); Assert.AreEqual(kExpectedValue, value); ////////////////////////////////////////////////////////////////////////// // Test the instance interface var streamer_instance = TypeCodeStreamer8.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_BinaryStreamerDownCastTest() { using (var ms = new System.IO.MemoryStream()) using (var br = new IO.EndianReader(ms)) using (var bw = new IO.EndianWriter(ms)) { const System.TypeCode kExpectedValue = System.TypeCode.String; var value = kExpectedValue; TypeCodeStreamer8.Write(bw, value); ms.Position = 0; TypeCodeStreamer8.Read(br, out value); Assert.IsTrue(value == kExpectedValue); ////////////////////////////////////////////////////////////////////////// // Test the instance interface var streamer_instance = TypeCodeStreamer8.Instance; ms.Position = 0; streamer_instance.Write(bw, value); ms.Position = 0; streamer_instance.Read(br, out value); Assert.IsTrue(value == kExpectedValue); } }