Пример #1
0
        public void ProvidedAnEntityWithNestedDeepLevelCollectionsProjectionUpdatesGraphs_UpdatedGraph_NoException()
        {
            DeepEntityFirstLevelWithDeepCollection firstEntity = new DeepEntityFirstLevelWithDeepCollection();
            firstEntity.Id = 1;
            firstEntity.Name = "I am the first level entity";
            firstEntity.SecondLevel = new DeepEntitySecondLevelWithDeepCollection()
            {
                Id = 2,
                Name = "I am the second level entity",
                ThirdLevel = new List<DeepEntityThirdLevelWithDeepCollection>()
                {
                    new DeepEntityThirdLevelWithDeepCollection()
                    {
                        Id = 3,
                        Name = "I am the third level entity",
                        FourthLevel = new List<DeepEntityFourthLevelWithDeepCollection>()
                        {
                            new DeepEntityFourthLevelWithDeepCollection()
                            {
                                Id = 4,
                                Name = "I am the fourth level entity",
                            }
                        }
                    }
                }
            };

            DeepProjectionFirstLevelWithDeepCollection projection = firstEntity.Project().To<DeepProjectionFirstLevelWithDeepCollection>();

            projection.Name = "I got changed";
            projection.SecondLevel.Name = "I got changed too";
            projection.SecondLevel.ThirdLevel.First().Name = "I also got changed as the other two";
            projection.SecondLevel.ThirdLevel.First().FourthLevel.First().Name = "I also got changed as the other three";

            projection.Project().To<DeepEntityFirstLevelWithDeepCollection>(firstEntity);

            Assert.IsTrue(firstEntity.Id == projection.Id, message: "Id should be exactly the same");
            Assert.IsTrue(firstEntity.Name == projection.Name, message: "Properties should be exactly the same");
            Assert.IsTrue(firstEntity.SecondLevel.Id == projection.SecondLevel.Id, message: "Second level Id should be exactly the same");
            Assert.IsTrue(firstEntity.SecondLevel.Name == projection.SecondLevel.Name, message: "Second level projection should have been mapped against second level entity properties");
            Assert.IsTrue(firstEntity.SecondLevel.ThirdLevel.First().Id == projection.SecondLevel.ThirdLevel.First().Id, message: "Third level Id should be exactly the same");
            Assert.IsTrue(firstEntity.SecondLevel.ThirdLevel.First().Name == projection.SecondLevel.ThirdLevel.First().Name, message: "Third level projection should have been mapped against third level entity properties");
            Assert.IsTrue(firstEntity.SecondLevel.ThirdLevel.First().FourthLevel.First().Id == projection.SecondLevel.ThirdLevel.First().FourthLevel.First().Id, message: "Fourth level Id should be exactly the same");
            Assert.IsTrue(firstEntity.SecondLevel.ThirdLevel.First().FourthLevel.First().Name == projection.SecondLevel.ThirdLevel.First().FourthLevel.First().Name, message: "Fourth level projection should have been mapped against third level entity properties");

        }
Пример #2
0
        public void ProvidedAnEntityWithNestedDeepLevelCollectionsTheMappingSucceds_ProjectedEntity_NoException()
        {
            DeepEntityFirstLevelWithDeepCollection firstEntity = new DeepEntityFirstLevelWithDeepCollection();
            firstEntity.Id = 1;
            firstEntity.Name = "I am the first level entity";
            firstEntity.SecondLevel = new DeepEntitySecondLevelWithDeepCollection()
            {
                Id = 2,
                Name = "I am the second level entity",
                ThirdLevel = new List<DeepEntityThirdLevelWithDeepCollection>()
                {
                    new DeepEntityThirdLevelWithDeepCollection()
                    {
                        Id = 3,
                        Name = "I am the third level entity",
                        FourthLevel = new List<DeepEntityFourthLevelWithDeepCollection>()
                        {
                            new DeepEntityFourthLevelWithDeepCollection()
                            {
                                Id = 4,
                                Name = "I am the fourth level entity",
                            }
                        }
                    }
                }
            };

            DeepProjectionFirstLevelWithDeepCollection projection = firstEntity.Project().To<DeepProjectionFirstLevelWithDeepCollection>();

            Assert.IsTrue(firstEntity.Id == projection.Id, message: "Id should be exactly the same");
            Assert.IsTrue(firstEntity.Name == projection.Name, message: "Properties should be exactly the same");
            Assert.IsTrue(firstEntity.SecondLevel.Id == projection.SecondLevel.Id, message: "Second level Id should be exactly the same");
            Assert.IsTrue(firstEntity.SecondLevel.Name == projection.SecondLevel.Name, message: "Second level projection should have been mapped against second level entity properties");
            Assert.IsTrue(firstEntity.SecondLevel.ThirdLevel.First().Id == projection.SecondLevel.ThirdLevel.First().Id, message: "Third level Id should be exactly the same");
            Assert.IsTrue(firstEntity.SecondLevel.ThirdLevel.First().Name == projection.SecondLevel.ThirdLevel.First().Name, message: "Third level projection should have been mapped against third level entity properties");
            Assert.IsTrue(firstEntity.SecondLevel.ThirdLevel.First().FourthLevel.First().Id == projection.SecondLevel.ThirdLevel.First().FourthLevel.First().Id, message: "Fourth level Id should be exactly the same");
            Assert.IsTrue(firstEntity.SecondLevel.ThirdLevel.First().FourthLevel.First().Name == projection.SecondLevel.ThirdLevel.First().FourthLevel.First().Name, message: "Fourth level projection should have been mapped against third level entity properties");

        }