Exemplo n.º 1
0
        public void IgnoringMemberIgnoresTheMember()
        {
            var mapper = new MemberMapper();

            var proposition = mapper.MappingStrategy.CreateMapProposal(
                new TypePair(typeof(Poco_From), typeof(Poco_To)),
                (ctx, option) =>
            {
                if (ctx.Source.Name == "ID")
                {
                    option.IgnoreMember();
                }
            }
                );

            var expectation = new ExpectedMappings <Poco_From, Poco_To>();

            expectation.Add(t => t.Name, t => t.Name);
            expectation.Add(t => t.OtherIDs, t => t.OtherIDs);

            Assert.IsTrue
            (
                ContainsMappingFor(proposition, expectation)
            );
        }
Exemplo n.º 2
0
        public void ExpectedPropertiesWillBeMapped()
        {
            var mapper = new MemberMapper();

            var proposition = mapper.MappingStrategy.CreateMapProposal(new TypePair(typeof(Poco_From), typeof(Poco_To)));

            proposition.FinalizeMap();

            var expectation = new ExpectedMappings <Poco_From, Poco_To>();

            expectation.Add(t => t.ID, t => t.ID);
            expectation.Add(t => t.Name, t => t.Name);
            expectation.Add(t => t.OtherIDs, t => t.OtherIDs);

            Assert.IsTrue
            (
                ContainsMappingFor(proposition, expectation)
            );
        }
Exemplo n.º 3
0
        public void FieldsAreMapped()
        {
            var mapper = new MemberMapper();

            var proposition = mapper.CreateMapProposal <SourceFields, DestinationFields>();

            var expectation = new ExpectedMappings <SourceFields, DestinationFields>();

            expectation.Add(t => t.ID, t => t.ID);

            Assert.IsTrue(ContainsMappingFor(proposition, expectation));
        }
Exemplo n.º 4
0
        public void ComplexListGetsMappedFromIEnumerable()
        {
            var mapper = new MemberMapper();

            var proposition = mapper.CreateMapProposal(typeof(IEnumerableComplexSourceType), typeof(ListComplexDestinationType));

            var expectation = new ExpectedMappings <IEnumerableComplexSourceType, ListComplexDestinationType>();

            expectation.Add(t => t.Source, t => t.Source);

            Assert.IsTrue(ContainsMappingFor(proposition, expectation));
        }
Exemplo n.º 5
0
        public void ListIntPropertyGetsMappedToArray()
        {
            var mapper = new MemberMapper();

            var proposition = mapper.CreateMapProposal(typeof(ListSourceType), typeof(ArrayDestinationType));

            var expectation = new ExpectedMappings <ListSourceType, ArrayDestinationType>();

            expectation.Add(t => t.Source, t => t.Source);

            Assert.IsTrue(ContainsMappingFor(proposition, expectation));
        }
Exemplo n.º 6
0
        public void ExpectedPropertiesFromInterfaceWillBeMapped()
        {
            var mapper = new MemberMapper();

            var proposition = mapper.MappingStrategy.CreateMapProposal(new TypePair(typeof(IPocoOneProperty_From), typeof(PocoOneProperty_To)));

            var expectation = new ExpectedMappings <IPocoOneProperty_From, PocoOneProperty_To>();

            expectation.Add(t => t.ID, t => t.ID);

            Assert.IsTrue
            (
                ContainsMappingFor(proposition, expectation)
            );
        }