Exemple #1
0
        public void Enum_BitStreamerTest()
        {
            const int k_bit_count = 32;

            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;
                    TypeCodeStreamer32.Write(s, value, k_bit_count);
                    s.Flush(); s.SeekToStart();
                    s.StreamMode = System.IO.FileAccess.Read;
                    TypeCodeStreamer32.Read(s, out value, k_bit_count);

                    Assert.AreEqual(kExpectedValue, value);

                    //////////////////////////////////////////////////////////////////////////
                    // Test the instance interface
                    var streamer_instance = TypeCodeStreamer32.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_BinaryStreamerTest()
        {
            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;

                        TypeCodeStreamer32.Write(bw, value);
                        ms.Position = 0;
                        TypeCodeStreamer32.Read(br, out value);

                        Assert.IsTrue(value == kExpectedValue);

                        //////////////////////////////////////////////////////////////////////////
                        // Test the instance interface
                        var streamer_instance = TypeCodeStreamer32.Instance;
                        ms.Position = 0;

                        streamer_instance.Write(bw, value);
                        ms.Position = 0;
                        streamer_instance.Read(br, out value);

                        Assert.IsTrue(value == kExpectedValue);
                    }
        }