예제 #1
0
            public void Must_not_throw_if_two_properties_are_mapped_together_as_ByIgnoring()
            {
                _configuration.Map(bar => bar.A).And(bar => bar.B).ByIgnoring();
                _configuration.Map(bar => bar.C).ByIgnoring();

                var systemUnderTest = new MappingMethodGenerator();

                Assert.DoesNotThrow(() => systemUnderTest.GenerateMappingMethod(_configuration));
            }
            public void Must_not_throw_if_static_properties_are_not_mapped()
            {
                _configuration.Map(bar => bar.A).From(foo => foo.A);
                _configuration.Map(bar => bar.B).From(foo => foo.B);
                _configuration.Map(bar => bar.C).ByIgnoring();

                var systemUnderTest = new MappingMethodGenerator();

                Assert.DoesNotThrow(() => systemUnderTest.GenerateMappingMethod(_configuration));
            }
            public void Must_not_throw_if_settable_properties_are_mapped_as_ByExecuting()
            {
                _configuration.Map(bar => bar.A).ByInvoking((bar1, foo1) => { });
                _configuration.Map(bar => bar.B).ByInvoking((bar1, foo1) => { });
                _configuration.Map(bar => bar.C).ByInvoking((bar1, foo1) => { });

                var systemUnderTest = new MappingMethodGenerator();

                Assert.DoesNotThrow(() => systemUnderTest.GenerateMappingMethod(_configuration));
            }
            public void Must_not_throw_if_read_only_properties_are_mapped_with_ByInvoking()
            {
                _configuration.Map(bar => bar.A).From(foo => foo.A);
                _configuration.Map(bar => bar.B).From(foo => foo.B);
                _configuration.Map(bar => bar.C).ByInvoking((bar1, foo1) => { });

                var systemUnderTest = new MappingMethodGenerator();

                Assert.DoesNotThrow(() => systemUnderTest.GenerateMappingMethod(_configuration));
            }
예제 #5
0
            public void Must_not_throw_if_read_only_properties_are_mapped_with_ByInvoking()
            {
                _configuration.Map(bar => bar.A).From(foo => foo.A);
                _configuration.Map(bar => bar.B).From(foo => foo.B);
                _configuration.Map(bar => bar.C).ByInvoking((bar1, foo1) => { });

                var systemUnderTest = new MappingMethodGenerator();

                Assert.DoesNotThrow(() => systemUnderTest.GenerateMappingMethod(_configuration));
            }
예제 #6
0
            public void Must_not_throw_if_static_properties_are_not_mapped()
            {
                _configuration.Map(bar => bar.A).From(foo => foo.A);
                _configuration.Map(bar => bar.B).From(foo => foo.B);
                _configuration.Map(bar => bar.C).ByIgnoring();

                var systemUnderTest = new MappingMethodGenerator();

                Assert.DoesNotThrow(() => systemUnderTest.GenerateMappingMethod(_configuration));
            }
예제 #7
0
            public void Must_not_throw_if_settable_properties_are_mapped_as_ByExecuting()
            {
                _configuration.Map(bar => bar.A).ByInvoking((bar1, foo1) => { });
                _configuration.Map(bar => bar.B).ByInvoking((bar1, foo1) => { });
                _configuration.Map(bar => bar.C).ByInvoking((bar1, foo1) => { });

                var systemUnderTest = new MappingMethodGenerator();

                Assert.DoesNotThrow(() => systemUnderTest.GenerateMappingMethod(_configuration));
            }
예제 #8
0
            public void Must_throw_if_read_only_properties_are_not_mapped()
            {
                _configuration.Map(bar => bar.A).From(foo => foo.A);
                _configuration.Map(bar => bar.B).From(foo => foo.B);

                var systemUnderTest = new MappingMethodGenerator();

                Assert.Throws <Exception>(
                    () => systemUnderTest.GenerateMappingMethod(_configuration),
                    String.Format("Mapping configuration is invalid.{0}A mapping was not provided for read-only target property 'Bar.C' from source 'Foo'.", Environment.NewLine));
            }
예제 #9
0
            public void Must_throw_if_read_only_properties_are_mapped_as_assignment()
            {
                _configuration.Map(bar => bar.A).From(foo => foo.A);
                _configuration.Map(bar => bar.B).From(foo => foo.B);
                _configuration.Map(bar => bar.C).From(foo => foo.C);

                var systemUnderTest = new MappingMethodGenerator();

                Assert.Throws <Exception>(
                    () => systemUnderTest.GenerateMappingMethod(_configuration),
                    String.Format(
                        "Mapping configuration is invalid.{0}A mapping was provided as an assignment for target property 'Bar.C' but the target property has no public instance setter.",
                        Environment.NewLine));
            }
예제 #10
0
            public void Must_throw_exception_if_base_class_properties_are_not_mapped()
            {
                var barSubClassConfiguration = new MapperConfiguration <Foo, BarSubClass>();

                barSubClassConfiguration.Map(target => target.SubClassProperty).From(source => false);

                var systemUnderTest = new MappingMethodGenerator();

                Assert.Throws <Exception>(
                    () => systemUnderTest.GenerateMappingMethod(barSubClassConfiguration),
                    String.Format(
                        "Mapping configuration is invalid.{0}A mapping was not provided for target property 'BarSubClass.A' from source 'Foo'.{0}A mapping was not provided for target property 'BarSubClass.B' from source 'Foo'.{0}A mapping was not provided for read-only target property 'BarSubClass.C' from source 'Foo'.",
                        Environment.NewLine));
            }
            public void Must_not_throw_if_two_properties_are_mapped_together_as_ByIgnoring()
            {
                _configuration.Map(bar => bar.A).And(bar => bar.B).ByIgnoring();
                _configuration.Map(bar => bar.C).ByIgnoring();

                var systemUnderTest = new MappingMethodGenerator();

                Assert.DoesNotThrow(() => systemUnderTest.GenerateMappingMethod(_configuration));
            }
            public void Must_throw_if_read_only_properties_are_not_mapped()
            {
                _configuration.Map(bar => bar.A).From(foo => foo.A);
                _configuration.Map(bar => bar.B).From(foo => foo.B);

                var systemUnderTest = new MappingMethodGenerator();

                Assert.Throws<Exception>(
                    () => systemUnderTest.GenerateMappingMethod(_configuration),
                    String.Format("Mapping configuration is invalid.{0}A mapping was not provided for read-only target property 'Bar.C' from source 'Foo'.", Environment.NewLine));
            }
            public void Must_throw_if_read_only_properties_are_mapped_as_assignment()
            {
                _configuration.Map(bar => bar.A).From(foo => foo.A);
                _configuration.Map(bar => bar.B).From(foo => foo.B);
                _configuration.Map(bar => bar.C).From(foo => foo.C);

                var systemUnderTest = new MappingMethodGenerator();

                Assert.Throws<Exception>(
                    () => systemUnderTest.GenerateMappingMethod(_configuration),
                    String.Format(
                        "Mapping configuration is invalid.{0}A mapping was provided as an assignment for target property 'Bar.C' but the target property has no public instance setter.",
                        Environment.NewLine));
            }
            public void Must_throw_exception_if_base_class_properties_are_not_mapped()
            {
                var barSubClassConfiguration = new MapperConfiguration<Foo, BarSubClass>();

                barSubClassConfiguration.Map(target => target.SubClassProperty).From(source => false);

                var systemUnderTest = new MappingMethodGenerator();

                Assert.Throws<Exception>(
                    () => systemUnderTest.GenerateMappingMethod(barSubClassConfiguration),
                    String.Format(
                        "Mapping configuration is invalid.{0}A mapping was not provided for target property 'BarSubClass.A' from source 'Foo'.{0}A mapping was not provided for target property 'BarSubClass.B' from source 'Foo'.{0}A mapping was not provided for read-only target property 'BarSubClass.C' from source 'Foo'.",
                        Environment.NewLine));
            }