public void Validate_Dto_With_Values_Enums()
        {
            var data = new FixtureExtensions().GetSubEntityWithValues();
            var actual = _tool.MapObject<FixturePublic.SubEntity, FixturePublic.Public4DTO>(data);

            var values = actual.GetType().GetProperties().Select(x => x.GetValue(actual));
            values.Should().NotContainNulls();
        }
Example #2
0
        public void Validate_Dto_When_The_Properties_Are_Equals()
        {
            var data = new FixtureExtensions().GetEntityWithValues();
            var actual = data.ConvertToDto<FixturePublic.Public2DTO>();

            var values = actual.GetType().GetProperties().Select(x => x.GetValue(actual));
            values.Should().NotContainNulls();
        }
        public void Validate_Dto_When_Sub_Entity_Converted_Dto()
        {
            var data = new FixtureExtensions().GetEntityWithValues();
            var actual = new FixturePublic.Public3DTO();
            _tool.MapObject(data, actual);

            var values = actual.GetType().GetProperties().Select(x => x.GetValue(actual));
            values.Should().NotContainNulls();
        }
        public void Validate_Expression_With_Customer_Property()
        {
            Expression<Func<FixturePublic.PublicDTO, bool>> expression = x => x.ThirdWithFourthWithSecond == 2;

            var data = new FixtureExtensions().GetListOfEntityWithValues();
            var expressionDto = expression.ConvertToExpressionEntity<FixturePublic.PublicDTO, FixturePublic.Entity>();
            var result = data.Where(expressionDto.Compile());

            Assert.Greater(result.Count(), 0);
        }
        public void Validate_Expression_With_Single_Property()
        {
            Expression<Func<FixturePublic.Public5DTO, bool>> expression = x => x.SecondProperty == "Test 2";

            var data = new FixtureExtensions().GetListOfEntityWithValues();
            var expressionEntity = expression.ConvertToExpressionEntity<FixturePublic.Public5DTO, FixturePublic.Entity>();
            var result = data.Where(expressionEntity.Compile());

            Assert.Greater(result.Count(), 0);
        }
        public void Validate_Entity_When_Sub_Entity_Converted_Dto()
        {
            var data = new FixtureExtensions().GetEntityWithValues();
            var dto = _tool.MapObject<FixturePublic.Entity, FixturePublic.Public3DTO>(data);
            var actual = _tool.ConvertToEntity<FixturePublic.Public3DTO, FixturePublic.Entity>(dto);

            Assert.IsNotNull(actual.Third.Third);

            //Get all values from actual.Third.Third
            var values = actual
                            .GetType()
                            .GetProperty("Third")
                            .GetValue(actual)
                            .GetType()
                            .GetProperties()
                            .Select(x => x.GetValue(actual
                                                    .GetType()
                                                    .GetProperty("Third")
                                                    .GetValue(actual)));
            values.Should().NotContainNulls();
        }
        public void Validate_Map_List_Entity_To_Dto_Only_The_Third_Property()
        {
            var listOfEntity = new FixtureExtensions().GetListEntityWithValuesInThirdProperty();

            //Get the values from the property "Second" from the property "Third"
            var expectValues = listOfEntity.Select(x => x.GetType()
                                                         .GetProperty("Third")
                                                         .GetValue(x)
                                                         .GetType()
                                                         .GetProperty("Second")
                                                         .GetValue(x.GetType()
                                                                    .GetProperty("Third")
                                                                    .GetValue(x))
                                                                    );
            //Convert all de list of entities to list of dtos
            var listOfDtos = _tool.MapList<FixturePublic.Entity, FixtureExtensions.DTO>(listOfEntity);

            var values = listOfDtos.Select(x => x.GetType().GetProperty("ThirdWithSecond").GetValue(x));

            values.ShouldAllBeEquivalentTo(expectValues);
        }
        public void Validate_Map_List_Entity_To_Dto_Only_The_Second_Property()
        {
            var listOfEntity = new FixtureExtensions().GetListOfEntityWithValuesInFirstAndSecondProperty();
            var expectValues = listOfEntity.Select(x => x.GetType().GetProperty("Second").GetValue(x));

            var listOfDtos = _tool.MapList<FixturePublic.Entity, FixtureExtensions.DTO>(listOfEntity);

            var values = listOfDtos.Select(x => x.GetType().GetProperty("SecondProperty").GetValue(x));

            values.ShouldAllBeEquivalentTo(expectValues);
        }
        public void Validate_Map_List_Dto_To_Entity_Only_The_Fourth_Property()
        {
            var listOfEntity = new FixtureExtensions().GetListEntityWithValuesInFourthProperty();

            //Get the values from the property "First" from the property "Fourth" from the property "Third"
            var expectValues = listOfEntity.Select(x => x.GetType()
                                                         .GetProperty("Third")
                                                         .GetValue(x)
                                                         .GetType()
                                                         .GetProperty("Fourth")
                                                         .GetValue(x.GetType()
                                                                    .GetProperty("Third")
                                                                    .GetValue(x)
                                                                   )
                                                          .GetType()
                                                          .GetProperty("First")
                                                          .GetValue(x.GetType()
                                                                     .GetProperty("Third")
                                                                     .GetValue(x)
                                                                     .GetType()
                                                                     .GetProperty("Fourth")
                                                                     .GetValue(x.GetType()
                                                                                .GetProperty("Third")
                                                                                .GetValue(x))
                                                                     )
                                                    );
            //Convert all de list of entities to list of dtos
            var listOfDtos = _tool.MapList<FixturePublic.Entity, FixtureExtensions.DTO>(listOfEntity);
            var listOfNewEntities = _tool.ConvertListToEntity<FixtureExtensions.DTO, FixtureExtensions.Entity>(listOfDtos);

            //Get all values from the la property "ThirdWithFourthWithSecond"
            var values = listOfNewEntities.Select(x => x.GetType()
                                                         .GetProperty("Third")
                                                         .GetValue(x)
                                                         .GetType()
                                                         .GetProperty("Fourth")
                                                         .GetValue(x.GetType()
                                                                    .GetProperty("Third")
                                                                    .GetValue(x)
                                                                   )
                                                          .GetType()
                                                          .GetProperty("First")
                                                          .GetValue(x.GetType()
                                                                     .GetProperty("Third")
                                                                     .GetValue(x)
                                                                     .GetType()
                                                                     .GetProperty("Fourth")
                                                                     .GetValue(x.GetType()
                                                                                .GetProperty("Third")
                                                                                .GetValue(x))
                                                                     )
                                                    );

            values.ShouldAllBeEquivalentTo(expectValues);
        }
        public void Validate_List_Of_Entity_With_Values_Enums()
        {
            var data = new FixtureExtensions().GetListSubEntityWithValues();
            var dto = _tool.MapList<FixturePublic.SubEntity, FixturePublic.Public4DTO>(data);
            var actual = _tool.ConvertListToEntity<FixturePublic.Public4DTO, FixturePublic.SubEntity>(dto);

            var values = actual.Select(y => y.GetType().GetProperties().Select(x => x.GetValue(actual)));
            values.Should().NotContainNulls();
        }
        public void Validate_Entity_With_Values_Enums()
        {
            var data = new FixtureExtensions().GetSubEntityWithValues();
            var dto = _tool.MapObject<FixturePublic.SubEntity, FixturePublic.Public4DTO>(data);
            var actual = _tool.ConvertToEntity<FixturePublic.Public4DTO, FixturePublic.SubEntity>(dto);

            Assert.IsTrue(actual.Second == data.Second);
        }
        public void Validate_Entity_When_The_Properties_Are_Equals()
        {
            var data = new FixtureExtensions().GetEntityWithValues();
            var dto = _tool.MapObject<FixturePublic.Entity, FixturePublic.Public2DTO>(data);
            var actual = _tool.ConvertToEntity<FixturePublic.Public2DTO, FixturePublic.Entity>(dto);

            var values = actual
                           .GetType()
                           .GetProperty("Third")
                           .GetValue(actual)
                           .GetType()
                           .GetProperties()
                           .Select(x => x.GetValue(actual
                                                   .GetType()
                                                   .GetProperty("Third")
                                                   .GetValue(actual)));
            values.Should().NotContainNulls();

            Assert.IsNotNullOrEmpty(actual.FirstProperty);
            Assert.IsNotNullOrEmpty(actual.Second);
        }
Example #13
0
        public void Validate_Map_List_Dto_To_Entity_Only_The_Second_Property()
        {
            var listOfEntity = new FixtureExtensions().GetListOfEntityWithValuesInFirstAndSecondProperty();
            var expectValues = listOfEntity.Select(x => x.GetType().GetProperty("Second").GetValue(x));

            var listOfDtos = listOfEntity.ConvertListToDto<FixtureExtensions.DTO>();
            var listOfNewEntities = listOfDtos.ConvertListToEntity<FixtureExtensions.Entity>();

            var values = listOfNewEntities.Select(x => x.GetType().GetProperty("Second").GetValue(x));

            values.ShouldAllBeEquivalentTo(expectValues);
        }
Example #14
0
        public void Validate_List_Of_Dto_With_Values_Enums()
        {
            var data = new FixtureExtensions().GetListSubEntityWithValues();
            var actual = data.ConvertListToDto<FixturePublic.Public4DTO>();

            var values = actual.Select(y => y.GetType().GetProperties().Select(x => x.GetValue(actual)));
            values.Should().NotContainNulls();
        }
Example #15
0
        public void Validate_Entity_With_Values_Enums()
        {
            var data = new FixtureExtensions().GetSubEntityWithValues();
            var dto = data.ConvertToDto<FixturePublic.Public4DTO>();
            var actual = dto.ConvertToEntity<FixturePublic.SubEntity>();

            Assert.IsTrue(actual.Second == data.Second);
        }
        public void Validate_List_Dto_When_The_Properties_Are_Equals()
        {
            var data = new FixtureExtensions().GetListOfEntityWithValues();
            var actual = _tool.MapList<FixturePublic.Entity, FixturePublic.Public2DTO>(data);

            var values = actual.Select(y => y.GetType().GetProperties().Select(x => x.GetValue(actual)));
            values.Should().NotContainNulls();
        }
        public void Validate_List_Entity_When_The_Properties_Are_Equals()
        {
            var data = new FixtureExtensions().GetListOfEntityWithValues();
            var listOfDtos = _tool.MapList<FixturePublic.Entity, FixturePublic.Public2DTO>(data);

            var listOfNewEntities = new List<FixturePublic.Entity>();
            _tool.ConvertListToEntity(listOfDtos, ref listOfNewEntities);

            var values = listOfNewEntities.Select(y => y.GetType().GetProperties().Select(x => x.GetValue(listOfNewEntities)));
            values.Should().NotContainNulls();
        }