Beispiel #1
0
        public void PropClassCollectionArray3()
        {
            CloneCollectionModel model = new CloneCollectionModel
            {
                ALNodes = new List <PropCloneNormalModel> [5]
            };

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

            var newModel = model.Clone();

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