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"); }
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); }
public void TestDateTimeToday() { Primatives p = new Primatives { TestDateTime = DateTime.Today }; Assert.AreEqual(p.TestDateTime, Serializer.DeepClone(p).TestDateTime); }
public void TestDateTimeNowSeconds() { Primatives p = new Primatives { TestDateTime = NowToSecond }; Assert.AreEqual(p.TestDateTime, Serializer.DeepClone(p).TestDateTime); }
public void TestDateTimeMaxValue() { Primatives p = new Primatives { TestDateTime = DateTime.MaxValue }; Assert.AreEqual(p.TestDateTime, Serializer.DeepClone(p).TestDateTime); }
public void TestDateTimeZero() { Primatives p = new Primatives { TestDateTime = new DateTime(1970, 1, 1) }; Assert.AreEqual(p.TestDateTime, Serializer.DeepClone(p).TestDateTime); }
public void TestDateTimeNowMillis() { Primatives p = new Primatives { TestDateTime = NowToMillisecond }; Assert.Equal(p.TestDateTime, Serializer.DeepClone(p).TestDateTime); }
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"); }
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); }
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); }
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"); }
public void TestDateTimeNowMillis() { Primatives p = new Primatives { TestDateTime = NowToMillisecond }; Assert.AreEqual(p.TestDateTime, Serializer.DeepClone(p).TestDateTime); }
public void TestDateTimeMinValue() { Primatives p = new Primatives { TestDateTime = DateTime.MinValue }; Assert.AreEqual(p.TestDateTime, Serializer.DeepClone(p).TestDateTime); }
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); }
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"); }
public void TestDateTimeZero() { Primatives p = new Primatives { TestDateTime = new DateTime(1970,1,1) }; Assert.AreEqual(p.TestDateTime, Serializer.DeepClone(p).TestDateTime); }