public void Deserialze(Deserializer serializedData)
 {
     Field1 = serializedData.GetInt32();
     Field2 = serializedData.GetInt32();
     Field3 = serializedData.GetString();
     nts    = new NestedTestSerialzer();
     nts.Deserialze(serializedData);
 }
Exemple #2
0
        public void GetStringFromDataWithOneStringSucces()
        {
            var originalData = "testHalloHelp";
            var data         = originalData.Length.ToString("D10") + originalData;
            var des          = new Deserializer(data);
            var result       = des.GetString();

            Assert.IsTrue(result == originalData);
        }
Exemple #3
0
        public void SerialzeAndDeserialze1StringSuccess()
        {
            var originalvalue = "MyTestString";

            ser.AddString(originalvalue);
            var serializedData = ser.FinalizeSerializationProcess();
            var des            = new Deserializer(serializedData);

            Assert.AreEqual(originalvalue, des.GetString());
        }
        private static void Main()
        {
            var serial = new Serializer();

            serial.AddInt32(0);
            serial.AddString("Pb4");
            serial.AddString("Pb4.1");
            serial.AddString("Update");

            var final = serial.FinalizeSerializationProcess();

            var des = new Deserializer(final);

            var i1 = des.GetInt32();
            var s1 = des.GetString();
            var s2 = des.GetString();
            var s3 = des.GetString();

            Console.WriteLine("blub");
        }
Exemple #5
0
        public void ReadStringAndBoolFromStringSuccess()
        {
            var data = "0000000005test1" +
                       "1" +
                       "0";
            var des = new Deserializer(data);

            Assert.AreEqual("test1", des.GetString());
            Assert.AreEqual(true, des.GetBool());
            Assert.AreEqual(false, des.GetBool());
        }
Exemple #6
0
        public void GetStringFromDataWithOneStringAndOneIntSucces()
        {
            var originalData = "testHalloHelp";
            var data         = originalData.Length.ToString("D10") + originalData;

            data = 123.ToString("D10") + data + 456.ToString("D10");
            var des = new Deserializer(data);

            Assert.AreEqual(123, des.GetInt32());
            Assert.IsTrue(des.GetString() == originalData);
            Assert.AreEqual(456, des.GetInt32());
        }
Exemple #7
0
        public void Serialize2IntsAndDeserialzeStringThrowsException()
        {
            var originalvalue  = -12569;
            var originalvalue2 = 987654;

            ser.AddInt32(originalvalue);
            ser.AddInt32(originalvalue2);
            var serializedData = ser.FinalizeSerializationProcess();
            var des            = new Deserializer(serializedData);

            Assert.AreEqual(originalvalue, des.GetInt32());
            Assert.Throws <ParserException>(() => { des.GetString(); });
        }
Exemple #8
0
        public void SerializeAndDeserialize4RandomValuesOfDifferentType()
        {
            var    rand          = new Random(Guid.NewGuid().GetHashCode());
            var    value1        = LongRandom(0, long.MaxValue, rand);
            var    value2        = rand.Next(0, int.MaxValue);
            double value3        = LongRandom(0, long.MinValue, rand) + rand.Next(0, 5000) / 1000;
            var    value4        = rand.Next() % 2 == 0;
            var    value5Builder = new StringBuilder();

            for (var i = 0; i < 50; i++)
            {
                //just using numbers as string. should still work
                value5Builder.Append(rand.Next());
            }

            var value5 = value5Builder.ToString();

            TestContext.Out.WriteLine($"long value:{value1}");
            TestContext.Out.WriteLine($"int value:{value2}");
            TestContext.Out.WriteLine($"double value:{value3}");
            TestContext.Out.WriteLine($"bool value:{value4}");
            TestContext.Out.WriteLine($"string value:{value5}");


            ser.AddLong(value1);
            ser.AddInt32(value2);
            ser.AddDouble(value3);
            ser.AddBool(value4);
            ser.AddString(value5);

            var final = ser.FinalizeSerializationProcess();
            var des   = new Deserializer(final);

            Assert.AreEqual(value1, des.GetLong());
            Assert.AreEqual(value2, des.GetInt32());
            Assert.AreEqual(value3, des.GetDouble());
            Assert.AreEqual(value4, des.GetBool());
            var value = des.GetString();

            Assert.AreEqual(value5, value);
        }
 public void Deserialze(Deserializer serializedData)
 {
     Field1 = serializedData.GetInt32();
     Field2 = serializedData.GetString();
 }