コード例 #1
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 = new FixturePublic.Entity();

            _tool.ConvertToEntity(dto, ref actual);

            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();
        }
コード例 #2
0
        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 = new FixturePublic.Entity();

            _tool.ConvertToEntity(dto, ref actual);

            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);
        }