public void TestEmptyMyListOfEntity() { var foos = new MyList(); var clone = Serializer.DeepClone(foos); Assert.IsNotNull(clone); }
public void TestEmtpyBasicListOfEntity() { var foos = new List <Entity>(); var clone = Serializer.DeepClone(foos); Assert.IsNotNull(clone); }
public void TestArrayContents() { Test3[] arr = new Test3[] { new Test3 { C = new Test1 { A = 123 } }, new Test3 { C = new Test1 { A = 456 } }, new Test3 { C = new Test1 { A = 789 } } }; var clone = Serializer.DeepClone(arr); CheckLists(arr, clone); }
public void TestListContents() { List <Test3> list = new List <Test3> { new Test3 { C = new Test1 { A = 123 } }, new Test3 { C = new Test1 { A = 456 } }, new Test3 { C = new Test1 { A = 789 } } }; var clone = Serializer.DeepClone(list); CheckLists(list, clone); }
public void TestEnumerableContents() { Test3Enumerable items = new Test3Enumerable { new Test3 { C = new Test1 { A = 123 } }, new Test3 { C = new Test1 { A = 456 } }, new Test3 { C = new Test1 { A = 789 } } }; var clone = Serializer.DeepClone(items); CheckLists(items, clone); }
public void TestStringArray() { var foo = new List <string> { "abc", "def", "ghi" }; var clone = Serializer.DeepClone(foo); }
static void VerifyNodeTree(Node node) { Node clone = Serializer.DeepClone(node); string msg; bool eq = AreEqual(node, clone, out msg); Assert.IsTrue(eq, msg); }
public void TestArrayBytes() { Test3[] list = new Test3[] { new Test3 { C = new Test1 { A = 150 } } }; Serializer.DeepClone(list); // variant? //Assert.IsTrue(Program.CheckBytes(list, 0x0A, 0x09, 0x1a, 0x07, 0x10, 0x01, 0x52, 0x03, 0x08, 0x96, 0x01)); }
public void PackedNullArrayDeserializesAsNull() { var item = new EntityWithPackedInts(); Assert.IsNull(item.ItemArray); var clone = Serializer.DeepClone(item); Assert.IsNull(clone.ItemArray); item.ItemArray = null; clone = Serializer.DeepClone(item); Assert.IsNull(clone.ItemArray); }
public void PackedNullListDeserializesAsNull() { var item = new EntityWithPackedInts(); Assert.IsNull(item.ListNoDefault); var clone = Serializer.DeepClone(item); Assert.IsNull(clone.ListNoDefault); item.ListNoDefault = null; clone = Serializer.DeepClone(item); Assert.IsNull(clone.ListNoDefault); }
public void TestUnpackedIntListLayout() { EntityWithUnpackedInts item = new EntityWithUnpackedInts { Items = { 1, 2, 3, 4, 5, 1000 } }; Assert.IsTrue(Program.CheckBytes(item, 08, 01, 08, 02, 08, 03, 08, 04, 08, 05, 08, 0xE8, 07)); var clone = Serializer.DeepClone(item); Assert.AreNotSame(item.Items, clone.Items); Assert.IsTrue(item.Items.SequenceEqual(clone.Items)); }
public void TestEmptyArrays() { Tst t = new Tst(); t.ValInt = 128; t.Str1 = "SOme string text value ttt"; t.ArrayData = new byte[] { }; MemoryStream stm = new MemoryStream(); Serializer.Serialize(stm, t); Console.WriteLine(stm.Length); }
public void TestPackedIntListLayout() { EntityWithPackedInts item = new EntityWithPackedInts { List = { 1, 2, 3, 4, 5, 1000 } }; Assert.IsTrue(Program.CheckBytes(item, 0x0A, 07, 01, 02, 03, 04, 05, 0xE8, 07)); var clone = Serializer.DeepClone(item); Assert.AreNotSame(item.List, clone.List); Assert.IsTrue(item.List.SequenceEqual(clone.List)); }
public void TestEnumerableBytes() { Test3Enumerable list = new Test3Enumerable { new Test3 { C = new Test1 { A = 150 } } }; Serializer.DeepClone(list); // Actual: 0A 05 1A 03 08 96 01 why, variant?? //Assert.IsTrue(Program.CheckBytes(list, 0x0A, 0x09, 0x1a, 0x07, 0x10, 0x01, 0x52, 0x03, 0x08, 0x96, 0x01)); }
public void TestListBytes() { List <Test3> list = new List <Test3> { new Test3 { C = new Test1 { A = 150 } } }; Serializer.DeepClone(list); // Actual 0A 05 1A 03 08 96 01 - don't know why, variant? //Assert.IsTrue(Program.CheckBytes(list, 0x0A, 0x09, 0x1a, 0x07, 0x10, 0x01, 0x52, 0x03, 0x08, 0x96, 0x01)); }
public void TestPackedIntArrayLayout() { EntityWithPackedInts item = new EntityWithPackedInts { ItemArray = new int[] { 1, 2, 3, 4, 5, 1000 } }; item.ClearList(); Assert.IsTrue(Program.CheckBytes(item, 0x1A, 07, 01, 02, 03, 04, 05, 0xE8, 07)); var clone = Serializer.DeepClone(item); Assert.AreNotSame(item.ItemArray, clone.ItemArray); Assert.IsTrue(item.ItemArray.SequenceEqual(clone.ItemArray)); }
public void JaggedByteArray() { var data = new[] { new byte[] { 0, 1, 2, 3, 4 }, new byte[] { 5, 6, 7 }, new byte[] { 8, 9, 10 } }; var clone = Serializer.DeepClone(data); Assert.AreNotSame(data, clone); Assert.AreEqual(3, clone.Length); Assert.IsTrue(data[0].SequenceEqual(clone[0])); Assert.IsTrue(data[1].SequenceEqual(clone[1])); Assert.IsTrue(data[2].SequenceEqual(clone[2])); }
public void TestPrimativeArray() { var schema = RuntimeTypeModel.Default.GetDebugSchema(typeof(Prim)); Prim p = new Prim { Values = new[] { "abc", "def", "ghi", "jkl" } }, clone = Serializer.DeepClone(p); string[] oldArr = p.Values, newArr = clone.Values; Assert.AreEqual(oldArr.Length, newArr.Length); for (int i = 0; i < oldArr.Length; i++) { Assert.AreEqual(oldArr[i], newArr[i], "Item " + i.ToString()); } }
public void CheckWrappedLinkedListCanRoundtrip() { var wrapper = new WithLinkedList(); wrapper.Items.AddLast(new BasicItem { Value = "abc" }); wrapper.Items.AddLast(new BasicItem { Value = "def" }); var clone = Serializer.DeepClone(wrapper); Assert.AreEqual(2, clone.Items.Count); Assert.AreEqual("abc", clone.Items.First.Value.Value); Assert.AreEqual("def", clone.Items.Last.Value.Value); }
public void TestUnpackedIntCustomLayout() { EntityWithUnpackedInts item = new EntityWithUnpackedInts { Custom = new CustomEnumerable { 1, 2, 3, 4, 5, 1000 } }; Assert.IsTrue(Program.CheckBytes(item, 0x20, 01, 0x20, 02, 0x20, 03, 0x20, 04, 0x20, 05, 0x20, 0xE8, 07)); var clone = Serializer.DeepClone(item); Assert.AreNotSame(item.Custom, clone.Custom); Assert.IsTrue(item.Custom.SequenceEqual(clone.Custom)); }
public void CheckNakedLinkedListCanRoundtrip() { var list = new LinkedList <BasicItem>(); list.AddLast(new BasicItem { Value = "abc" }); list.AddLast(new BasicItem { Value = "def" }); var clone = Serializer.DeepClone(list); Assert.AreEqual(2, clone.Count); Assert.AreEqual("abc", clone.First.Value.Value); Assert.AreEqual("def", clone.Last.Value.Value); }
public void ListOfByteArray() { var data = new List <byte[]> { new byte[] { 0, 1, 2, 3, 4 }, new byte[] { 5, 6, 7 }, new byte[] { 8, 9, 10 }, new byte[] {} }; var clone = Serializer.DeepClone(data); Assert.AreNotSame(data, clone); Assert.AreEqual(4, clone.Count); Assert.IsTrue(data[0].SequenceEqual(clone[0])); Assert.IsTrue(data[1].SequenceEqual(clone[1])); Assert.IsTrue(data[2].SequenceEqual(clone[2])); Assert.IsTrue(data[3].SequenceEqual(clone[3])); }
public void PackedEmptyCustomDeserializesAsEmpty() { var item = new EntityWithPackedInts(); Assert.IsNull(item.Custom); var clone = Serializer.DeepClone(item); Assert.IsNull(clone.Custom); item.Custom = new CustomEnumerable(); clone = Serializer.DeepClone(item); Assert.IsNotNull(clone.Custom); Assert.AreEqual(0, clone.Custom.Count()); item.Custom.Add(123); clone = Serializer.DeepClone(item); Assert.IsNotNull(clone.Custom); Assert.AreEqual(123, item.Custom.Single()); }
public void PackedEmptyListDeserializesAsEmpty() { var item = new EntityWithPackedInts(); Assert.IsNull(item.ListNoDefault); EntityWithPackedInts clone;// = Serializer.DeepClone(item); //Assert.IsNull(clone.ListNoDefault); item.ListNoDefault = new List <int>(); clone = Serializer.DeepClone(item); Assert.IsNotNull(clone.ListNoDefault); Assert.AreEqual(0, clone.ListNoDefault.Count); item.ListNoDefault.Add(123); clone = Serializer.DeepClone(item); Assert.IsNotNull(clone.ListNoDefault); Assert.AreEqual(1, clone.ListNoDefault.Count); Assert.AreEqual(123, clone.ListNoDefault[0]); }
public void TestNonEmptyMyListOfEntity() { var foos = new MyList() { new Entity { Foo = "abc" }, new Entity { Foo = "def" }, }; var clone = Serializer.DeepClone(foos); Assert.IsNotNull(clone); Assert.AreNotSame(foos, clone); Assert.AreEqual(foos.GetType(), clone.GetType()); Assert.AreEqual(2, clone.Count); Assert.AreEqual(foos[0].Foo, clone[0].Foo); Assert.AreEqual(foos[1].Foo, clone[1].Foo); }
public void TestCompositeDictionary() { DictionaryTestEntity obj = new DictionaryTestEntity { Foo = "bar", Stuff = { { "abc", CompositeType.Create(123) }, { "def", CompositeType.Create(DateTime.Today) }, { "ghi", CompositeType.Create("hello world") }, } }, clone = Serializer.DeepClone(obj); Assert.IsNotNull(clone); Assert.AreNotSame(clone, obj); Assert.AreEqual("bar", clone.Foo); Assert.AreEqual(3, clone.Stuff.Count); Assert.AreEqual(123, clone.Stuff["abc"].Value); Assert.AreEqual(DateTime.Today, clone.Stuff["def"].Value); Assert.AreEqual("hello world", clone.Stuff["ghi"].Value); }
public void PackedEmptyArrayDeserializesAsEmpty() { var item = new EntityWithPackedInts(); Assert.IsNull(item.ItemArray); var clone = Serializer.DeepClone(item); Assert.IsNull(clone.ItemArray); item.ItemArray = new int[0]; clone = Serializer.DeepClone(item); Assert.IsNotNull(clone.ItemArray); Assert.AreEqual(0, clone.ItemArray.Length); item.ItemArray = new int[1] { 123 }; clone = Serializer.DeepClone(item); Assert.IsNotNull(clone.ItemArray); Assert.AreEqual(1, clone.ItemArray.Length); Assert.AreEqual(123, clone.ItemArray[0]); }
public void TestPackedCustomOfSubMessage() { Serializer.DeepClone(new CustomOfSubMessage()); }
public void TestPackedListDateTime() { Serializer.DeepClone(new ListOfDateTime()); }
public void TestPackedArrayString() { Serializer.DeepClone(new ArrayOfString()); }