Esempio n. 1
0
        public void PropClassCollectionTest()
        {
            PropCloneClassCollectionModel model = new PropCloneClassCollectionModel();

            model.Nodes = new List <PropCloneNormalModel>();
            for (int i = 0; i < 10; i++)
            {
                model.Nodes.Add(new PropCloneNormalModel()
                {
                    Age = i, Name = i.ToString()
                });
            }

            SnapshotOperator.MakeSnapshot(model);

            for (int i = 5; i < 10; i++)
            {
                model.Nodes.Add(new PropCloneNormalModel()
                {
                    Age = i + 100, Name = (i + 100).ToString()
                });
            }


            var reuslt = SnapshotOperator.Compare(model);
            var value  = (HashSet <PropCloneNormalModel>)reuslt["Nodes"].Value;
            int temp   = 5;

            foreach (var item in value)
            {
                Assert.Equal(temp.ToString(), item.Name);
                Assert.Equal(temp, item.Age);
                temp++;
            }
        }
Esempio n. 2
0
        public void PropClassCollectionTest()
        {
            PropCloneClassCollectionModel model = new PropCloneClassCollectionModel();

            model.Nodes = new List <PropCloneNormalModel>();
            for (int i = 0; i < 10; i++)
            {
                model.Nodes.Add(new PropCloneNormalModel()
                {
                    Age = i, Name = i.ToString()
                });
            }

            var newModel = CloneOperator.Clone(model);

            for (int i = 0; i < 10; i++)
            {
                Assert.NotEqual(model.Nodes, newModel.Nodes);
                Assert.Equal(model.Nodes[i].Name, newModel.Nodes[i].Name);
                Assert.Equal(model.Nodes[i].Age, newModel.Nodes[i].Age);
            }
        }
Esempio n. 3
0
        public void PropClassCollectionArray()
        {
            PropCloneClassCollectionModel model = new PropCloneClassCollectionModel();

            model.Nodes = new List <PropCloneNormalModel>();
            for (int i = 0; i < 10; i++)
            {
                model.Nodes.Add(new PropCloneNormalModel()
                {
                    Age = i, Name = i.ToString()
                });
            }

            CloneBuilder <PropCloneClassCollectionModel> .CreateCloneDelegate();

            var newModel = DeepClone <PropCloneClassCollectionModel> .Clone(model);

            for (int i = 0; i < 10; i++)
            {
                Assert.Equal(model.Nodes[i].Name, newModel.Nodes[i].Name);
                Assert.Equal(model.Nodes[i].Age, newModel.Nodes[i].Age);
            }
        }