public void MapSourceToDestination_NonGenericMetod_TSourceAndSourceObjHaveDifferentTypes()
        {
            var mapper = new Mapper();

            mapper.CreateConfiguration <MockSource, MockDestination>()
            .AddMap(s => s.GuidProp, d => d.GuidProp)
            .AddMap(s => s.StringProp, d => d.StringProp)
            .AddMap(s => s.IntProp, d => d.IntProp)
            .AddMap(s => s.DateTimeProp, d => d.DateTimeProp)
            .AddMap(s => s.DoubleProp, d => d.DoubleProp);

            var source = new MockSource1()
            {
                GuidProp   = Guid.NewGuid(),
                StringProp = "anyString",
                IntProp    = 1234
            };

            var result = (MockDestination)mapper.Map(typeof(MockSource), typeof(MockDestination), source);
        }
        public void MapperForSourceIsNotImplemented_Exception()
        {
            var mapper = new Mapper();

            mapper.CreateConfiguration <MockSource, MockDestination>()
            .AddMap(s => s.GuidProp, d => d.GuidProp)
            .AddMap(s => s.StringProp, d => d.StringProp)
            .AddMap(s => s.IntProp, d => d.IntProp)
            .AddMap(s => s.DateTimeProp, d => d.DateTimeProp)
            .AddMap(s => s.DoubleProp, d => d.DoubleProp);

            var source = new MockSource1()
            {
                GuidProp   = Guid.NewGuid(),
                StringProp = "anyString",
                IntProp    = 1234
            };

            var result = mapper.Map <MockSource1, MockDestination>(source);
        }
        public void MapSourceWithCollectionAndReferenceProperty_MapperForCollectionIsNotImplemented()
        {
            var mapper = new Mapper();

            mapper.CreateConfiguration <MockSource1, MockDestination1>()
            .AddMap(s => s.GuidProp, d => d.GuidProp)
            .AddMap(s => s.StringProp, d => d.StringProp)
            .AddMap(s => s.IntProp, d => d.IntProp);

            mapper.CreateConfiguration <MockSource, MockDestination>()
            .AddMap(s => s.GuidProp, d => d.GuidProp)
            .AddMap(s => s.StringProp, d => d.StringProp)
            .AddMap(s => s.IntProp, d => d.IntProp)
            .AddMap(s => s.DateTimeProp, d => d.DateTimeProp)
            .AddMap(s => s.DoubleProp, d => d.DoubleProp)
            .AddMap(s => s.ReferenceProperty, d => d.ReferenceProperty);

            var sourceRef1 = new MockSource1()
            {
                GuidProp   = Guid.NewGuid(),
                StringProp = "anySourceRef1",
                IntProp    = 12
            };

            var sourceRef2 = new MockSource1()
            {
                GuidProp   = Guid.NewGuid(),
                StringProp = "anySourceRef2",
                IntProp    = 23
            };

            var source = new MockSource()
            {
                GuidProp          = Guid.NewGuid(),
                StringProp        = "anyString",
                IntProp           = 1234,
                DateTimeProp      = DateTime.Now,
                DoubleProp        = 123.456,
                ReferenceProperty = new MockSource1()
                {
                    GuidProp   = Guid.NewGuid(),
                    StringProp = "anyRefString",
                    IntProp    = 456
                },
                CollectionOfReferenceProperties = new List <MockSource1>()
                {
                    sourceRef1, sourceRef2
                }
            };

            var result = mapper.Map <MockSource, MockDestination>((new List <MockSource>()
            {
                source
            }).AsQueryable());

            var destination = result.FirstOrDefault(d => d.GuidProp == source.GuidProp);

            Assert.IsNotNull(destination, "destination is null.");
            Assert.AreEqual(source.StringProp, destination.StringProp, "source StringProp error.");
            Assert.AreEqual(source.IntProp, destination.IntProp, "source IntProp error.");
            Assert.AreEqual(source.DateTimeProp, destination.DateTimeProp, "source DateTimeProp error.");
            Assert.AreEqual(source.DoubleProp, destination.DoubleProp, "source DoubleProp error.");

            Assert.AreEqual(source.ReferenceProperty.GuidProp, destination.ReferenceProperty.GuidProp, "source ReferenceProperty.GuidProp error.");
            Assert.AreEqual(source.ReferenceProperty.StringProp, destination.ReferenceProperty.StringProp, "source ReferenceProperty.StringProp error.");
            Assert.AreEqual(source.ReferenceProperty.IntProp, destination.ReferenceProperty.IntProp, "source ReferenceProperty.IntProp error.");

            Assert.IsNull(destination.CollectionOfReferenceProperties, "CollectionOfReferenceProperties is not null.");
        }