예제 #1
0
        public void MapsEnumerableOfDtosUsingInterfaces()
        {
            IEnumerable <IDto> dtos = new IDto[]
            {
                new Dto1
                {
                    P0 = 10,
                    P1 = 11
                },
                new Dto2
                {
                    P0 = 20,
                    P2 = 22
                }
            };

            var domainObjects = this.mapper.Map <IEnumerable <IDomainType> >(dtos).ToArray();

            domainObjects.Length.ShouldBe(dtos.Count());

            var domainObject1 = domainObjects[0].ShouldBeOfType <DomainType1>();

            domainObject1.Prop0.ShouldBe(10);
            domainObject1.Prop1.ShouldBe(11);

            var domainObject2 = domainObjects[1].ShouldBeOfType <DomainType2>();

            domainObject2.Prop0.ShouldBe(20);
            domainObject2.Prop2.ShouldBe(22);
        }