Exemple #1
0
        public void ProvidedTwoNonFlatEntitiesWithMatchingNamesProjectWorks_ProjectedEntity_NoException()
        {
            NotSoFlatEntity entity = new NotSoFlatEntity();
            entity.Id = 1;
            entity.Name = "I am the entity";
            entity.Nestedentity = new BasicEntity()
            {
                Id = 2,
                Name = "I am the nested entity"
            };
            entity.Nestedfield = new BasicEntity()
            {
                Id = 3,
                Name = "I am the nested field"
            };

            NotSoFlatProjection projection = entity.Project().To<NotSoFlatProjection>();

            Assert.IsTrue(entity.Id.Equals(projection.Id), message: "Id struct should be exactly the same");
            Assert.IsTrue(entity.Name == projection.Name, message: "Properties should be exactly the same");
            Assert.IsTrue(entity.Nestedentity.Id == projection.Nestedentity.Id, message: "Nested entity should be exactly the same");
            Assert.IsTrue(entity.Nestedentity.Name == projection.Nestedentity.Name, message: "Nested entity should be exactly the same");
            Assert.IsTrue(entity.Nestedfield.Id == projection.Nestedfield.Id, message: "Nested field should be exactly the same");
            Assert.IsTrue(entity.Nestedfield.Name == projection.Nestedfield.Name, message: "Nested field should be exactly the same");
        }
Exemple #2
0
        public void ProvidedOneNonFlatEntityAndAConventionBasedFlattenedProjectionWithMatchingNamesProjectWorksOneWay_ProjectedEntity_NoException()
        {
            NotSoFlatEntity entity = new NotSoFlatEntity();
            entity.Id = 1;
            entity.Name = "I am the entity";
            entity.Nestedentity = new BasicEntity()
            {
                Id = 2,
                Name = "I am the nested entity"
            };
            entity.Nestedfield = new BasicEntity()
            {
                Id = 3,
                Name = "I am the nested field"
            };

            FlatConventionBasedProjection projection = entity.Project().To<FlatConventionBasedProjection>();

            Assert.IsTrue(entity.Id.Equals(projection.Id), message: "Id struct should be exactly the same");
            Assert.IsTrue(entity.Name == projection.Name, message: "Properties should be exactly the same");
            Assert.IsTrue(entity.Nestedentity.Id == projection.NestedentityId, message: "Nested entity should have been mapped against flattened properties");
            Assert.IsTrue(entity.Nestedentity.Name == projection.NestedentityName, message: "Nested entity should have been mapped against flattened properties");
            Assert.IsTrue(entity.Nestedfield.Id == projection.NestedfieldId, message: "Nested field should be exactly the same");
            Assert.IsTrue(entity.Nestedfield.Name == projection.NestedfieldName, message: "Nested field should be exactly the same");
        }