Beispiel #1
0
        public void ClassCollectionArray()
        {
            FieldCloneClassCollectionModel model = new FieldCloneClassCollectionModel
            {
                Nodes = new List <FieldCloneNormalModel>()
            };

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

            var newModel = CloneOperator.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);
                Assert.NotEqual(i - 1, newModel.Nodes[i].Age);
            }
            model.Nodes.Clear();
            Assert.NotEqual(model.Nodes.Count, newModel.Nodes.Count);
        }
Beispiel #2
0
        public void ClassCollectionArray()
        {
            FieldCloneClassCollectionModel model = new FieldCloneClassCollectionModel();

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

            SnapshotOperator.MakeSnapshot(model);

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


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

            foreach (var item in value)
            {
                Assert.Equal(temp.ToString(), item.Name);
                Assert.Equal(temp, item.Age);
                temp++;
            }
        }
Beispiel #3
0
        public void ClassCollectionArray()
        {
            FieldCloneClassCollectionModel model = new FieldCloneClassCollectionModel();

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

            CloneBuilder <FieldCloneClassCollectionModel> .CreateCloneDelegate();

            var newModel = DeepClone <FieldCloneClassCollectionModel> .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);
            }
        }