public void RetrieveIntValuePropertyGetter_NoConversion()
        {
            var propertyGetterFactory = new AutoMapperEnabledPropertyGetterFactory(
                new NameMatcher((from, to) =>
            {
                return(from == "intValue" && to == "IntValue");
            }),
                getBasicAutoMapperConfiguration()
                );
            var propertyGetter = propertyGetterFactory.TryToGet(
                typeof(SourceType),
                "intValue",
                typeof(int)
                );

            // Does the returned property getter appear valid?
            Assert.NotNull(propertyGetter);
            Assert.AreEqual(typeof(SourceType), propertyGetter.SrcType);
            Assert.AreEqual(typeof(SourceType).GetProperty("IntValue"), propertyGetter.Property);
            Assert.AreEqual(typeof(int), propertyGetter.TargetType);

            // Does it actually retrieve data correctly?
            var src = new SourceType()
            {
                IntValue = 3
            };

            Assert.AreEqual(3, propertyGetter.GetValue(src));
        }
        public void RetrieveIntValuePropertyGetter_AsSourceType_WithoutMapping()
        {
            var propertyGetterFactory = new AutoMapperEnabledPropertyGetterFactory(
                new NameMatcher((from, to) =>
            {
                return(from == "intValue" && to == "IntValue");
            }),
                getBasicAutoMapperConfiguration()
                );
            var propertyGetter = propertyGetterFactory.TryToGet(
                typeof(SourceType),
                "intValue",
                typeof(SourceType)
                );

            // Does the returned property getter appear valid?
            Assert.Null(propertyGetter);
        }
        public void RetrieveIntValuePropertyGetter_AsSourceType()
        {
            var mappingConfig = getBasicAutoMapperConfiguration();

            mappingConfig.CreateMap <int, SourceType>().ConstructUsing(x => new SourceType()
            {
                IntValue = x
            });
            var propertyGetterFactory = new AutoMapperEnabledPropertyGetterFactory(
                new NameMatcher((from, to) =>
            {
                return(from == "intValue" && to == "IntValue");
            }),
                mappingConfig
                );
            var propertyGetter = propertyGetterFactory.TryToGet(
                typeof(SourceType),
                "intValue",
                typeof(SourceType)
                );

            // Does the returned property getter appear valid?
            Assert.NotNull(propertyGetter);
            Assert.AreEqual(typeof(SourceType), propertyGetter.SrcType);
            Assert.AreEqual(typeof(SourceType).GetProperty("IntValue"), propertyGetter.Property);
            Assert.AreEqual(typeof(SourceType), propertyGetter.TargetType);

            // Does it actually retrieve data correctly?
            var src = new SourceType()
            {
                IntValue = 3
            };
            var expected = new SourceType()
            {
                IntValue = 3
            };

            Assert.True(Common.DoSerialisableObjectsHaveMatchingContent(expected, propertyGetter.GetValue(src)));
        }