Example #1
0
 public void Deserialize(ITeslaReader reader)
 {
     reader.ReadObjectBegin("SampleClass");
     m_int       = reader.ReadInt32("m_int");
     m_byte      = reader.ReadByte("m_byte");
     m_longarray = (List <long>)reader.ReadInt64Array("m_longarray", false, 1);
     m_string    = reader.ReadString("m_string", false);
     m_obj       = reader.ReadObject <InnerClass>("m_obj", true);
     reader.ReadObjectEnd("SampleClass");
 }
Example #2
0
        public void ReadObjectTest()
        {
            InnerClass expected = new InnerClass()
            {
                m_bool = true, m_double = 0.1, m_float = 150
            };
            List <byte> lb = new List <byte>();

            lb.AddRange(BitConverter.GetBytes(expected.m_float));
            lb.AddRange(BitConverter.GetBytes(expected.m_double));
            lb.Add((byte)(expected.m_bool ? 0xD : 0x5));
            BinaryReader reader = new BinaryReader(lb.ToArray(), DeserializationHelper.CannedVersion);

            InnerClass actual = reader.ReadObject <InnerClass>(string.Empty, false);

            Assert.AreEqual <InnerClass>(expected, actual);
        }
Example #3
0
        public override bool Equals(System.Object obj)
        {
            // If parameter is null return false.
            if (obj == null)
            {
                return(false);
            }

            // If parameter cannot be cast to Point return false.
            InnerClass b = obj as InnerClass;

            if ((System.Object)b == null)
            {
                return(false);
            }

            // Return true if the fields match:
            return((Math.Abs(this.m_float - b.m_float) < 1E-25) && (Math.Abs(this.m_double - b.m_double) < 1E-25) && (this.m_bool == b.m_bool));
        }
Example #4
0
        public void WriteObjectTest()
        {
            InnerClass innerClass = new InnerClass()
            {
                m_bool = true, m_double = 0.1, m_float = 150
            };

            List <byte> expected = new List <byte>();

            expected.AddRange(BitConverter.GetBytes(innerClass.m_float));
            expected.AddRange(BitConverter.GetBytes(innerClass.m_double));
            expected.Add((byte)(innerClass.m_bool ? 0xD : 0x5));

            System.IO.MemoryStream actual = new System.IO.MemoryStream();

            BinaryWriter writer = new BinaryWriter(actual, BinaryWriterTest.CannedVersion);

            writer.Write(string.Empty, innerClass, false);

            TestHelper.AssertCollectionEquals <byte>(expected.ToArray(), actual.ToArray());
        }
Example #5
0
        public void ObjectTest()
        {
            InnerClass expected = new InnerClass()
            {
                m_bool = true, m_double = 0.1, m_float = 150
            };

            System.IO.MemoryStream stream = new System.IO.MemoryStream();
            BinaryWriter           writer = new BinaryWriter(stream, RoundtripTest.CannedVersion);

            expected.Serialize(writer);

            stream.Seek(0L, System.IO.SeekOrigin.Begin);

            BinaryReader reader = new BinaryReader(stream, RoundtripTest.CannedVersion);

            InnerClass actual = new InnerClass();

            actual.Deserialize(reader);

            Assert.AreEqual <InnerClass>(expected, actual);
        }
Example #6
0
 public void Deserialize(ITeslaReader reader)
 {
     reader.ReadObjectBegin("SampleClass");
     m_int = reader.ReadInt32("m_int");
     m_byte = reader.ReadByte("m_byte");
     m_longarray = (List<long>)reader.ReadInt64Array("m_longarray", false, 1);
     m_string = reader.ReadString("m_string", false);
     m_obj = reader.ReadObject<InnerClass>("m_obj", true);
     reader.ReadObjectEnd("SampleClass");
 }