Ejemplo n.º 1
0
        public void TestDecimalExtremes()
        {
            Primatives p = new Primatives(), clone;

            p.TestDecimalDefault = decimal.MaxValue;
            clone = Serializer.DeepClone(p);
            Assert.AreEqual(p.TestDecimalDefault, clone.TestDecimalDefault, "Max");

            p.TestDecimalDefault = decimal.MaxValue - 1234.5M;
            clone = Serializer.DeepClone(p);
            Assert.AreEqual(p.TestDecimalDefault, clone.TestDecimalDefault, "Nearly max");

            p.TestDecimalDefault = decimal.MinValue;
            clone = Serializer.DeepClone(p);
            Assert.AreEqual(p.TestDecimalDefault, clone.TestDecimalDefault, "Min");

            p.TestDecimalDefault = decimal.MinValue + 1234.5M;
            clone = Serializer.DeepClone(p);
            Assert.AreEqual(p.TestDecimalDefault, clone.TestDecimalDefault, "Nearly min");

            p.TestDecimalDefault = 0.00000000000000000000000123M;
            clone = Serializer.DeepClone(p);
            Assert.AreEqual(p.TestDecimalDefault, clone.TestDecimalDefault, "Very small +ve");

            p.TestDecimalDefault = -p.TestDecimalDefault;
            clone = Serializer.DeepClone(p);
            Assert.AreEqual(p.TestDecimalDefault, clone.TestDecimalDefault, "Very small -ve");
        }
Ejemplo n.º 2
0
 public void TestBoolean()
 {
     Primatives p = new Primatives { TestBoolean = true };
     Assert.AreEqual(p.TestBoolean, Serializer.DeepClone(p).TestBoolean);
     p.TestBoolean = false;
     Assert.AreEqual(p.TestBoolean, Serializer.DeepClone(p).TestBoolean);
 }
Ejemplo n.º 3
0
        public void TestDateTimeToday()
        {
            Primatives p = new Primatives {
                TestDateTime = DateTime.Today
            };

            Assert.AreEqual(p.TestDateTime, Serializer.DeepClone(p).TestDateTime);
        }
Ejemplo n.º 4
0
        public void TestDateTimeNowSeconds()
        {
            Primatives p = new Primatives {
                TestDateTime = NowToSecond
            };

            Assert.AreEqual(p.TestDateTime, Serializer.DeepClone(p).TestDateTime);
        }
Ejemplo n.º 5
0
        public void TestDateTimeMaxValue()
        {
            Primatives p = new Primatives {
                TestDateTime = DateTime.MaxValue
            };

            Assert.AreEqual(p.TestDateTime, Serializer.DeepClone(p).TestDateTime);
        }
Ejemplo n.º 6
0
        public void TestDateTimeZero()
        {
            Primatives p = new Primatives {
                TestDateTime = new DateTime(1970, 1, 1)
            };

            Assert.AreEqual(p.TestDateTime, Serializer.DeepClone(p).TestDateTime);
        }
Ejemplo n.º 7
0
        public void TestDateTimeNowMillis()
        {
            Primatives p = new Primatives {
                TestDateTime = NowToMillisecond
            };

            Assert.Equal(p.TestDateTime, Serializer.DeepClone(p).TestDateTime);
        }
Ejemplo n.º 8
0
        public void TestBoolean()
        {
            Primatives p = new Primatives {
                TestBoolean = true
            };

            Assert.AreEqual(p.TestBoolean, Serializer.DeepClone(p).TestBoolean);
            p.TestBoolean = false;
            Assert.AreEqual(p.TestBoolean, Serializer.DeepClone(p).TestBoolean);
        }
Ejemplo n.º 9
0
        public void TestString()
        {
            Primatives p = new Primatives();

            p.TestString = "";
            Assert.AreEqual(p.TestString, Serializer.DeepClone(p).TestString, "Empty");
            p.TestString = "foo";
            Assert.AreEqual(p.TestString, Serializer.DeepClone(p).TestString, "Non-empty");
            p.TestString = null;
            Assert.AreEqual(p.TestString, Serializer.DeepClone(p).TestString, "Null");
        }
Ejemplo n.º 10
0
        public void TestDecimalUnits()
        {
            Primatives p = new Primatives {
                TestDecimalDefault = decimal.Zero
            };

            Assert.AreEqual(p.TestDecimalDefault, Serializer.DeepClone(p).TestDecimalDefault);

            p.TestDecimalDefault = decimal.MinusOne;
            Assert.AreEqual(p.TestDecimalDefault, Serializer.DeepClone(p).TestDecimalDefault);

            p.TestDecimalDefault = decimal.One;
            Assert.AreEqual(p.TestDecimalDefault, Serializer.DeepClone(p).TestDecimalDefault);

            p = Program.Build <Primatives>(0x1A, 0x00);
            Assert.AreEqual(decimal.Zero, p.TestDecimalDefault);

            p = Program.Build <Primatives>();
            Assert.AreEqual(29M, p.TestDecimalDefault);
        }
Ejemplo n.º 11
0
        public void TestDecimalUnits()
        {
            Primatives p = new Primatives {
                TestDecimalDefault = decimal.Zero
            };
            var tm = TypeModel.Create(false, ProtoCompatibilitySettingsValue.FullCompatibility);

            Assert.AreEqual(p.TestDecimalDefault, tm.DeepClone(p).TestDecimalDefault);

            p.TestDecimalDefault = decimal.MinusOne;
            Assert.AreEqual(p.TestDecimalDefault, tm.DeepClone(p).TestDecimalDefault);

            p.TestDecimalDefault = decimal.One;
            Assert.AreEqual(p.TestDecimalDefault, tm.DeepClone(p).TestDecimalDefault);

            p = Program.Build <Primatives>(0x1A, 0x00);
            Assert.AreEqual(decimal.Zero, p.TestDecimalDefault);

            p = Program.Build <Primatives>();
            Assert.AreEqual(29M, p.TestDecimalDefault);
        }
Ejemplo n.º 12
0
        public void TestDecimal()
        {
            Primatives p = new Primatives();

            p.TestDecimalDefault = 123456.789M; //p.TestDecimalTwos = p.TestDecimalZigZag =

            Primatives clone = Serializer.DeepClone(p);

            Assert.AreEqual(p.TestDecimalDefault, clone.TestDecimalDefault, "Default +ve");
            //Assert.AreEqual(p.TestDecimalTwos, clone.TestDecimalTwos, "Twos +ve");
            //Assert.AreEqual(p.TestDecimalZigZag, clone.TestDecimalZigZag, "ZigZag +ve");

            p.TestDecimalDefault = -123456.789M; //p.TestDecimalTwos = p.TestDecimalZigZag =
            clone = Serializer.DeepClone(p);
            Assert.AreEqual(p.TestDecimalDefault, clone.TestDecimalDefault, "Default -ve");
            //Assert.AreEqual(p.TestDecimalTwos, clone.TestDecimalTwos, "Twos -ve");
            //Assert.AreEqual(p.TestDecimalZigZag, clone.TestDecimalZigZag, "ZigZag -ve");

            p.TestDecimalDefault = 0; // p.TestDecimalTwos = p.TestDecimalZigZag = 0;
            clone = Serializer.DeepClone(p);
            Assert.AreEqual(p.TestDecimalDefault, clone.TestDecimalDefault, "Default 0");
            //Assert.AreEqual(p.TestDecimalTwos, clone.TestDecimalTwos, "Twos 0");
            //Assert.AreEqual(p.TestDecimalZigZag, clone.TestDecimalZigZag, "ZigZag 0");

            p.TestDecimalDefault = decimal.Parse("0.000"); // p.TestDecimalTwos = p.TestDecimalZigZag =
            clone = Serializer.DeepClone(p);
            Assert.AreEqual(p.TestDecimalDefault, clone.TestDecimalDefault, "Default 0.000");
            //Assert.AreEqual(p.TestDecimalTwos, clone.TestDecimalTwos, "Twos 0.000");
            //Assert.AreEqual(p.TestDecimalZigZag, clone.TestDecimalZigZag, "ZigZag 0.000");

            p.TestDecimalDefault = decimal.Parse("1.000"); //p.TestDecimalTwos = p.TestDecimalZigZag =
            clone = Serializer.DeepClone(p);
            Assert.AreEqual(p.TestDecimalDefault, clone.TestDecimalDefault, "Default 1.000");
            //Assert.AreEqual(p.TestDecimalTwos, clone.TestDecimalTwos, "Twos 1.000");
            //Assert.AreEqual(p.TestDecimalZigZag, clone.TestDecimalZigZag, "ZigZag 1.000");
        }
Ejemplo n.º 13
0
 public void TestDateTimeNowMillis()
 {
     Primatives p = new Primatives { TestDateTime = NowToMillisecond };
     Assert.AreEqual(p.TestDateTime, Serializer.DeepClone(p).TestDateTime);
 }
Ejemplo n.º 14
0
 public void TestDateTimeToday()
 {
     Primatives p = new Primatives { TestDateTime = DateTime.Today };
     Assert.AreEqual(p.TestDateTime, Serializer.DeepClone(p).TestDateTime);
 }
Ejemplo n.º 15
0
 public void TestDateTimeMinValue()
 {
     Primatives p = new Primatives { TestDateTime = DateTime.MinValue };
     Assert.AreEqual(p.TestDateTime, Serializer.DeepClone(p).TestDateTime);
 }
Ejemplo n.º 16
0
 public void TestString()
 {
     Primatives p = new Primatives();
     p.TestString = "";
     Assert.AreEqual(p.TestString, Serializer.DeepClone(p).TestString, "Empty");
     p.TestString = "foo";
     Assert.AreEqual(p.TestString, Serializer.DeepClone(p).TestString, "Non-empty");
     p.TestString = null;
     Assert.AreEqual(p.TestString, Serializer.DeepClone(p).TestString, "Null");
 }
Ejemplo n.º 17
0
        public void TestDecimalUnits()
        {
            Primatives p = new Primatives { TestDecimalDefault = decimal.Zero};
            Assert.AreEqual(p.TestDecimalDefault, Serializer.DeepClone(p).TestDecimalDefault);

            p.TestDecimalDefault = decimal.MinusOne;
            Assert.AreEqual(p.TestDecimalDefault, Serializer.DeepClone(p).TestDecimalDefault);

            p.TestDecimalDefault = decimal.One;
            Assert.AreEqual(p.TestDecimalDefault, Serializer.DeepClone(p).TestDecimalDefault);

            p = Program.Build<Primatives>(0x1A, 0x00);
            Assert.AreEqual(decimal.Zero, p.TestDecimalDefault);

            p = Program.Build<Primatives>();
            Assert.AreEqual(29M, p.TestDecimalDefault);
        }
Ejemplo n.º 18
0
        public void TestDecimalExtremes()
        {
            Primatives p = new Primatives(), clone;

            p.TestDecimalDefault = decimal.MaxValue;
            clone = Serializer.DeepClone(p);
            Assert.AreEqual(p.TestDecimalDefault, clone.TestDecimalDefault, "Max");

            p.TestDecimalDefault = decimal.MaxValue - 1234.5M;
            clone = Serializer.DeepClone(p);
            Assert.AreEqual(p.TestDecimalDefault, clone.TestDecimalDefault, "Nearly max");

            p.TestDecimalDefault = decimal.MinValue;
            clone = Serializer.DeepClone(p);
            Assert.AreEqual(p.TestDecimalDefault, clone.TestDecimalDefault, "Min");

            p.TestDecimalDefault = decimal.MinValue + 1234.5M;
            clone = Serializer.DeepClone(p);
            Assert.AreEqual(p.TestDecimalDefault, clone.TestDecimalDefault, "Nearly min");

            p.TestDecimalDefault = 0.00000000000000000000000123M;
            clone = Serializer.DeepClone(p);
            Assert.AreEqual(p.TestDecimalDefault, clone.TestDecimalDefault, "Very small +ve");

            p.TestDecimalDefault = -p.TestDecimalDefault;
            clone = Serializer.DeepClone(p);
            Assert.AreEqual(p.TestDecimalDefault, clone.TestDecimalDefault, "Very small -ve");
        }
Ejemplo n.º 19
0
        public void TestDecimal()
        {
            Primatives p = new Primatives();
            p.TestDecimalDefault = 123456.789M; //p.TestDecimalTwos = p.TestDecimalZigZag =

            Primatives clone = Serializer.DeepClone(p);
            Assert.AreEqual(p.TestDecimalDefault,clone.TestDecimalDefault, "Default +ve");
            //Assert.AreEqual(p.TestDecimalTwos, clone.TestDecimalTwos, "Twos +ve");
            //Assert.AreEqual(p.TestDecimalZigZag, clone.TestDecimalZigZag, "ZigZag +ve");

            p.TestDecimalDefault = -123456.789M; //p.TestDecimalTwos = p.TestDecimalZigZag =
            clone = Serializer.DeepClone(p);
            Assert.AreEqual(p.TestDecimalDefault, clone.TestDecimalDefault, "Default -ve");
            //Assert.AreEqual(p.TestDecimalTwos, clone.TestDecimalTwos, "Twos -ve");
            //Assert.AreEqual(p.TestDecimalZigZag, clone.TestDecimalZigZag, "ZigZag -ve");

            p.TestDecimalDefault = 0; // p.TestDecimalTwos = p.TestDecimalZigZag = 0;
            clone = Serializer.DeepClone(p);
            Assert.AreEqual(p.TestDecimalDefault, clone.TestDecimalDefault, "Default 0");
            //Assert.AreEqual(p.TestDecimalTwos, clone.TestDecimalTwos, "Twos 0");
            //Assert.AreEqual(p.TestDecimalZigZag, clone.TestDecimalZigZag, "ZigZag 0");

            p.TestDecimalDefault = decimal.Parse("0.000"); // p.TestDecimalTwos = p.TestDecimalZigZag =
             clone = Serializer.DeepClone(p);
            Assert.AreEqual(p.TestDecimalDefault, clone.TestDecimalDefault, "Default 0.000");
            //Assert.AreEqual(p.TestDecimalTwos, clone.TestDecimalTwos, "Twos 0.000");
            //Assert.AreEqual(p.TestDecimalZigZag, clone.TestDecimalZigZag, "ZigZag 0.000");

            p.TestDecimalDefault = decimal.Parse("1.000"); //p.TestDecimalTwos = p.TestDecimalZigZag =
            clone = Serializer.DeepClone(p);
            Assert.AreEqual(p.TestDecimalDefault, clone.TestDecimalDefault, "Default 1.000");
            //Assert.AreEqual(p.TestDecimalTwos, clone.TestDecimalTwos, "Twos 1.000");
            //Assert.AreEqual(p.TestDecimalZigZag, clone.TestDecimalZigZag, "ZigZag 1.000");
        }
Ejemplo n.º 20
0
 public void TestDateTimeZero()
 {
     Primatives p = new Primatives { TestDateTime = new DateTime(1970,1,1) };
     Assert.AreEqual(p.TestDateTime, Serializer.DeepClone(p).TestDateTime);
 }