public void Test_DictionaryOfObjects() { var val = new Dictionary <string, PocoSimple>() { { "1", new PocoSimple() { Int = 1, Str = "1" } }, { "2", new PocoSimple() { Int = 2, Str = "2" } }, { "3", new PocoSimple() { Int = 3, Str = "3" } }, { "4", null } }; var buf = BinaryConvert.SerializeObject(val); var cloned = BinaryConvert.DeserializeObject <Dictionary <string, PocoSimple> >(buf); CollectionAssert.AreEqual( val.OrderBy(x => x.Key).ToList(), cloned.OrderBy(x => x.Key).ToList()); }
public override bool Equals(object other) { var bufThis = BinaryConvert.SerializeObject(this); var bufOhter = BinaryConvert.SerializeObject(other as PocoWithAllPrimitives); return(ArrayEqualityComparer <byte> .Equals(bufThis, bufOhter)); }
public void Test_BooleanTrue() { Boolean val = true; var buf = BinaryConvert.SerializeObject(val); var cloned = BinaryConvert.DeserializeObject <Boolean>(buf); Assert.AreEqual(val, cloned); }
public void Test_SingleNegative() { float val = -1234.1f; var buf = BinaryConvert.SerializeObject(val); var cloned = BinaryConvert.DeserializeObject <float>(buf); Assert.AreEqual(val, cloned); }
public void Test_StringNull() { string val = null; var buf = BinaryConvert.SerializeObject(val); var cloned = BinaryConvert.DeserializeObject <string>(buf); Assert.AreEqual(val, cloned); }
public void Test_Default() { var val = default(DateTime); var buf = BinaryConvert.SerializeObject(val); var cloned = BinaryConvert.DeserializeObject <DateTime>(buf); Assert.AreEqual(val, cloned); }
public void Test_String() { var val = "Hello World"; var buf = BinaryConvert.SerializeObject(val); var cloned = BinaryConvert.DeserializeObject <string>(buf); Assert.AreEqual(val, cloned); }
public void Test_Constants() { var val = new Guid("F9168C5E-CEB2-4faa-B6BF-329BF39FA1E4"); var buf = BinaryConvert.SerializeObject(val); var cloned = BinaryConvert.DeserializeObject <Guid>(buf); Assert.AreEqual(val, cloned); }
public void Test_RandomNewGuid() { var val = Guid.NewGuid(); var buf = BinaryConvert.SerializeObject(val); var cloned = BinaryConvert.DeserializeObject <Guid>(buf); Assert.AreEqual(val, cloned); }
public void Test_Empty() //same as default... { var val = Guid.Empty; var buf = BinaryConvert.SerializeObject(val); var cloned = BinaryConvert.DeserializeObject <Guid>(buf); Assert.AreEqual(val, cloned); }
public void Test_StringNonGeneric() { var val = "Hello World"; var buf = BinaryConvert.SerializeObject(typeof(string), val); var cloned = BinaryConvert.DeserializeObject(typeof(string), buf); Assert.AreEqual(val, cloned); }
public void Test_UInt32() { uint val = 1234; var buf = BinaryConvert.SerializeObject(val); var cloned = BinaryConvert.DeserializeObject <uint>(buf); Assert.AreEqual(val, cloned); }
public void Test_DoubleNegative() { double val = -1234.1f; var buf = BinaryConvert.SerializeObject(val); var cloned = BinaryConvert.DeserializeObject <double>(buf); Assert.AreEqual(val, cloned); }
public void Test_Int32Min() { int val = Int32.MinValue; var buf = BinaryConvert.SerializeObject(val); var cloned = BinaryConvert.DeserializeObject <int>(buf); Assert.AreEqual(val, cloned); }
public void Test_Char() { char val = 'x'; var buf = BinaryConvert.SerializeObject(val); var cloned = BinaryConvert.DeserializeObject <char>(buf); Assert.AreEqual(val, cloned); }
public void Test_Int32Negative() { int val = -1234; var buf = BinaryConvert.SerializeObject(val); var cloned = BinaryConvert.DeserializeObject <int>(buf); Assert.AreEqual(val, cloned); }
public void Test_Int16() { Int16 val = 1234; var buf = BinaryConvert.SerializeObject(val); var cloned = BinaryConvert.DeserializeObject <Int16>(buf); Assert.AreEqual(val, cloned); }
public void Test_UInt64Max() { UInt64 val = UInt64.MaxValue; var buf = BinaryConvert.SerializeObject(val); var cloned = BinaryConvert.DeserializeObject <UInt64>(buf); Assert.AreEqual(val, cloned); }
public void Test_SByte() { SByte val = -12; var buf = BinaryConvert.SerializeObject(val); var cloned = BinaryConvert.DeserializeObject <SByte>(buf); Assert.AreEqual(val, cloned); }
public void Test_Int32NullableWithNull() { int?val = null; var buf = BinaryConvert.SerializeObject(val); var cloned = BinaryConvert.DeserializeObject <int?>(buf); Assert.AreEqual(val, cloned); }
public void Test_Int64Min() { Int64 val = Int64.MinValue; var buf = BinaryConvert.SerializeObject(val); var cloned = BinaryConvert.DeserializeObject <Int64>(buf); Assert.AreEqual(val, cloned); }
public void Test_Tuple_N6() { var val = new Tuple <int, string, decimal, double, string, byte>(1, "1", 1.23m, 3.3, null, 7); var buf = BinaryConvert.SerializeObject(val); var cloned = BinaryConvert.DeserializeObject <Tuple <int, string, decimal, double, string, byte> >(buf); Assert.AreEqual(val, cloned); }
public void Test_PocoComplexNotInitialized() { var val = new PocoComplex(); var buf = BinaryConvert.SerializeObject(val); var cloned = BinaryConvert.DeserializeObject <PocoComplex>(buf); Assert.AreEqual(val, cloned); }
public void Test_Tuple_N1() { var val = new Tuple <int>(1); var buf = BinaryConvert.SerializeObject(val); var cloned = BinaryConvert.DeserializeObject <Tuple <int> >(buf); Assert.AreEqual(val, cloned); }
public void Test_ListNull() { HashSet <string> val = null; var buf = BinaryConvert.SerializeObject(val); var cloned = BinaryConvert.DeserializeObject <HashSet <string> >(buf); Assert.AreEqual(val, cloned); }
public void Test_DictionaryEmpty() { var val = new Dictionary <string, int>(); var buf = BinaryConvert.SerializeObject(val); var cloned = BinaryConvert.DeserializeObject <Dictionary <string, int> >(buf); CollectionAssert.AreEqual(val, cloned); }
public void Test_Tuple_N3() { var val = new Tuple <int, string, decimal>(1, "1", 1.23m); var buf = BinaryConvert.SerializeObject(val); var cloned = BinaryConvert.DeserializeObject <Tuple <int, string, decimal> >(buf); Assert.AreEqual(val, cloned); }
public void Test_ListEmpty() { var val = new HashSet <string>(); var buf = BinaryConvert.SerializeObject(val); var cloned = BinaryConvert.DeserializeObject <HashSet <string> >(buf); CollectionAssert.AreEqual(val.OrderBy(x => x).ToList(), cloned.OrderBy(x => x).ToList()); }
public void Test_Tuple_N8Rest() { var val = new Tuple <int, string, decimal, double, string, byte, DateTime, Tuple <int, string> >(1, "1", 1.23m, 3.3, null, 7, new DateTime(2010, 10, 10, 10, 10, 10), new Tuple <int, string>(2, "2")); var buf = BinaryConvert.SerializeObject(val); var cloned = BinaryConvert.DeserializeObject <Tuple <int, string, decimal, double, string, byte, DateTime, Tuple <int, string> > >(buf); Assert.AreEqual(val, cloned); }
public void Test_PocosNull() { PocoSimple val = null; var buf = BinaryConvert.SerializeObject(val); var cloned = BinaryConvert.DeserializeObject <PocoSimple>(buf); Assert.AreEqual(val, cloned); }