コード例 #1
0
        public void Test_List_Serialize_Work()
        {
            var list  = CreateTestListWithTracker();
            var data  = MessagePackSerializer.Serialize(list, TestResolver.GetMessagePackOption());
            var list2 = MessagePackSerializer.Deserialize <TrackableList <string> >(data, TestResolver.GetMessagePackOption());

            Assert.Equal(list.Count, list2.Count);
        }
コード例 #2
0
        public void Test_Dictionary_Serialize_Work()
        {
            var dict  = CreateTestDictionaryWithTracker();
            var data  = MessagePackSerializer.Serialize(dict, TestResolver.GetMessagePackOption());
            var dict2 = MessagePackSerializer.Deserialize <TrackableDictionary <int, string> >(data, TestResolver.GetMessagePackOption());

            Assert.Equal(dict.Count, dict2.Count);
        }
コード例 #3
0
        public void Test_Set_Serialize_Work()
        {
            var set       = CreateTestSetWithTracker();
            var serialize = MessagePackSerializer.Serialize(set, TestResolver.GetMessagePackOption());
            var set2      = MessagePackSerializer.Deserialize <TrackableSet <int> >(serialize, TestResolver.GetMessagePackOption());

            Assert.Equal(set.Count, set2.Count);
        }
コード例 #4
0
ファイル: ContainerTest.cs プロジェクト: tteogi/TrackableData
        public void Test_Container_Serialize_Work()
        {
            var c    = CreateTestContainerWithTracker();
            var data = MessagePackSerializer.Serialize(c, TestResolver.GetMessagePackOption());
            var c2   = MessagePackSerializer.Deserialize <TrackableDataContainer>(data, TestResolver.GetMessagePackOption());

            Assert.Equal(c.Dictionary.Count, c2.Dictionary.Count);
            Assert.Equal(c.List.Count, c2.List.Count);
        }
コード例 #5
0
        public void Test_PocoTracker_Serialize_Work()
        {
            var person = CreateTestPersonWithTracker();

            person.Name = "Bob";
            person.Age  = 30;

            var serialize = MessagePackSerializer.Serialize(person.Tracker, TestResolver.GetMessagePackOption());
            var tracker2  =
                MessagePackSerializer.Deserialize <TrackablePocoTracker <IPerson> >(serialize, TestResolver.GetMessagePackOption());

            var person2 = CreateTestPerson();

            tracker2.ApplyTo(person2);

            Assert.Equal(person.Name, person2.Name);
            Assert.Equal(person.Age, person2.Age);
        }
コード例 #6
0
        public void Test_SetTracker_Serialize_Work()
        {
            var set = CreateTestSetWithTracker();

            set.Remove(1);
            set.Remove(2);
            set.Add(4);
            set.Add(5);

            var serialize = MessagePackSerializer.Serialize(set.Tracker, TestResolver.GetMessagePackOption());
            var tracker2  = MessagePackSerializer.Deserialize <TrackableSetTracker <int> >(serialize, TestResolver.GetMessagePackOption());

            var set2 = CreateTestSet();

            tracker2.ApplyTo(set2);

            Assert.Equal(new HashSet <int> {
                5, 4, 3
            },
                         set2);
        }
コード例 #7
0
ファイル: ContainerTest.cs プロジェクト: tteogi/TrackableData
        public void Test_ContainerTracker_Serialize_Work()
        {
            var c = CreateTestContainerWithTracker();

            // Act

            c.Person.Name = "Bob";
            c.Person.Age  = 30;

            c.Dictionary[1] = "OneModified";
            c.Dictionary.Remove(2);
            c.Dictionary[4] = "FourAdded";

            c.List[0] = "OneModified";
            c.List.RemoveAt(1);
            c.List.Insert(1, "TwoInserted");

            c.Set.Remove(1);
            c.Set.Remove(2);
            c.Set.Add(4);
            c.Set.Add(5);

            // Assert

            var data     = MessagePackSerializer.Serialize(c.Tracker, TestResolver.GetMessagePackOption());
            var tracker2 = MessagePackSerializer.Deserialize <TrackableDataContainerTracker>(data, TestResolver.GetMessagePackOption());

            var c2 = CreateTestContainer();

            tracker2.ApplyTo(c2);

            Assert.Equal(c.Person.Name, c2.Person.Name);
            Assert.Equal(c.Person.Age, c2.Person.Age);
            Assert.Equal(c.Dictionary.OrderBy(x => x.Key), c2.Dictionary.OrderBy(x => x.Key));
            Assert.Equal(c.List, c2.List);
            Assert.Equal(c.Set.OrderBy(x => x), c2.Set.OrderBy(x => x));
        }
コード例 #8
0
        public void Test_DictionaryTracker_Serialize_Work()
        {
            var dict = CreateTestDictionaryWithTracker();

            dict[1] = "OneModified";
            dict.Remove(2);
            dict[4] = "FourAdded";

            var data     = MessagePackSerializer.Serialize(dict.Tracker, TestResolver.GetMessagePackOption());
            var tracker2 = MessagePackSerializer.Deserialize <TrackableDictionaryTracker <int, string> >(data, TestResolver.GetMessagePackOption());

            var dict2 = CreateTestDictionary();

            tracker2.ApplyTo(dict2);

            Assert.Equal(
                new[]
            {
                new KeyValuePair <int, string>(1, "OneModified"),
                new KeyValuePair <int, string>(3, "Three"),
                new KeyValuePair <int, string>(4, "FourAdded")
            },
                dict2.OrderBy(kv => kv.Key));
        }
コード例 #9
0
        public void Test_ListTracker_Serialize_Work()
        {
            var list = CreateTestListWithTracker();

            list[0] = "OneModified";
            list.RemoveAt(1);
            list.Insert(1, "TwoInserted");
            list.Insert(0, "Zero");
            list.RemoveAt(0);
            list.Insert(0, "ZeroAgain");
            list.Insert(4, "Four");
            list.RemoveAt(4);
            list.Insert(4, "FourAgain");

            var data     = MessagePackSerializer.Serialize(list.Tracker, TestResolver.GetMessagePackOption());
            var tracker2 = MessagePackSerializer.Deserialize <TrackableListTracker <string> >(data, TestResolver.GetMessagePackOption());

            var list2 = CreateTestList();

            tracker2.ApplyTo(list2);

            Assert.Equal(new[] { "ZeroAgain", "OneModified", "TwoInserted", "Three", "FourAgain" },
                         list2);
        }
コード例 #10
0
 public void Test_Poco_Serialize_Work()
 {
     var person    = CreateTestPersonWithTracker();
     var serialize = MessagePackSerializer.Serialize(person, TestResolver.GetMessagePackOption());
     var person2   = MessagePackSerializer.Deserialize <TrackablePerson>(serialize, TestResolver.GetMessagePackOption());
 }