public void ProvidedOneEntityWithThreeDepthLevelsWithProjectionMatchingNamesButNullSecondLevelProjectWorksOneWay_ProjectedEntity_NoException() { DeepEntityFirstLevel firstEntity = new DeepEntityFirstLevel(); firstEntity.Id = 1; firstEntity.Name = "I am the first level entity"; firstEntity.SecondLevel = null; DeepProjectionFirstLevel projection = firstEntity.Project().To<DeepProjectionFirstLevel>(); 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 == null, message: "This value should be null as it was null in the entity"); }
public void ProvidedExistingEntityWithThreeDepthLevelsProjectionUpdatesProjectWorks_UpdatedEntity_NoException() { DeepEntityFirstLevel firstEntity = new DeepEntityFirstLevel(); firstEntity.Id = 1; firstEntity.Name = "I am the first level entity"; firstEntity.SecondLevel = new DeepEntitySecondLevel() { Id = 2, Name = "I am the second level entity", ThirdLevel = new DeepEntityThirdLevel() { Id = 3, Name = "I am the third level entity", } }; DeepProjectionFirstLevel projection = firstEntity.Project().To<DeepProjectionFirstLevel>(); projection.Name = "I got changed"; projection.SecondLevel.Name = "I got changed too"; projection.SecondLevel.ThirdLevel.Name = "I also got changed as the other two"; projection.Project().To<DeepEntityFirstLevel>(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.Id == projection.SecondLevel.ThirdLevel.Id, message: "Third level Id should be exactly the same"); Assert.IsTrue(firstEntity.SecondLevel.ThirdLevel.Name == projection.SecondLevel.ThirdLevel.Name, message: "Third level projection should have been mapped against third level entity properties"); }
public void ProvidedOneEntityWithThreeDepthLevelsWithProjectionMatchingNamesProjectWorksOneWay_ProjectedEntity_NoException() { DeepEntityFirstLevel firstEntity = new DeepEntityFirstLevel(); firstEntity.Id = 1; firstEntity.Name = "I am the first level entity"; firstEntity.SecondLevel = new DeepEntitySecondLevel() { Id = 2, Name = "I am the second level entity", ThirdLevel = new DeepEntityThirdLevel() { Id = 3, Name = "I am the third level entity", } }; DeepProjectionFirstLevel projection = firstEntity.Project().To<DeepProjectionFirstLevel>(); 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 entity should have been mapped against second level projection properties"); Assert.IsTrue(firstEntity.SecondLevel.Name == projection.SecondLevel.Name, message: "Second level entity should have been mapped against second level projection properties"); Assert.IsTrue(firstEntity.SecondLevel.ThirdLevel.Id == projection.SecondLevel.ThirdLevel.Id, message: "Third level entity should have been mapped against third level projection properties"); Assert.IsTrue(firstEntity.SecondLevel.ThirdLevel.Name == projection.SecondLevel.ThirdLevel.Name, message: "Third level entity should have been mapped against third level projection properties"); }