예제 #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");
        }
예제 #2
0
        public void ProvidedTwoNonFlatEntitiesWithMatchingNamesProjectWorksOverQueryable_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"
            };

            List<NotSoFlatEntity> entityList = new List<NotSoFlatEntity>() { entity };

            List<NotSoFlatProjection> projectionList = entityList.ProjectEnumerable().To<NotSoFlatProjection>().ToList();

            Assert.IsTrue(entityList.Count() == projectionList.Count(), message: "Same number of elements should be in both lists");
            Assert.IsTrue(entityList[0].Id.Equals(projectionList[0].Id), message: "Id struct should be exactly the same");
            Assert.IsTrue(entityList[0].Name == projectionList[0].Name, message: "Properties should be exactly the same");
            Assert.IsTrue(entityList[0].Nestedentity.Id == projectionList[0].Nestedentity.Id, message: "Nested entity should be exactly the same");
            Assert.IsTrue(entityList[0].Nestedentity.Name == projectionList[0].Nestedentity.Name, message: "Nested entity should be exactly the same");
            Assert.IsTrue(entityList[0].Nestedfield.Id == projectionList[0].Nestedfield.Id, message: "Nested field should be exactly the same");
            Assert.IsTrue(entityList[0].Nestedfield.Name == projectionList[0].Nestedfield.Name, message: "Nested field should be exactly the same");
        }
예제 #3
0
        public void ProvidedOneNonFlatEntityAndAConventionBasedFlattenedProjectionWithMatchingNamesProjectWorksOverQueryableOneWay_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"
            };
            entity.IDoNotMapWithAnyThing = new BasicEntity()
            {
                Id = 4,
                Name = "I will never be mapped"
            };

            List<NotSoFlatEntity> entityList = new List<NotSoFlatEntity>() { entity };

            List<FlatConventionBasedProjection> projectionList = entityList.ProjectEnumerable().To<FlatConventionBasedProjection>().ToList();

            Assert.IsTrue(entityList.Count() == projectionList.Count(), message: "Same number of elements should be in both lists");
            Assert.IsTrue(entityList[0].Id.Equals(projectionList[0].Id), message: "Id struct should be exactly the same");
            Assert.IsTrue(entityList[0].Name == projectionList[0].Name, message: "Properties should be exactly the same");
            Assert.IsTrue(entityList[0].Nestedentity.Id == projectionList[0].NestedentityId, message: "Nested entity should have been mapped against flattened properties");
            Assert.IsTrue(entityList[0].Nestedentity.Name == projectionList[0].NestedentityName, message: "Nested entity should have been mapped against flattened properties");
            Assert.IsTrue(entityList[0].Nestedfield.Id == projectionList[0].NestedfieldId, message: "Nested field should be exactly the same");
            Assert.IsTrue(entityList[0].Nestedfield.Name == projectionList[0].NestedfieldName, message: "Nested field should be exactly the same");
        }
예제 #4
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");
        }