public void Should_silently_skip_unmatching_value_when_allowing_type_validation() { var mapper = new DynamicObjectMapper(new DynamicObjectMapperSettings { SilentlySkipUnassignableMembers = true }); var obj = mapper.Map<CustomType>(dynamicObject); obj.ShouldNotBeNull(); }
public void Should_throw_when_preventing_type_validation() { var mapper = new DynamicObjectMapper(new DynamicObjectMapperSettings { SilentlySkipUnassignableMembers = false }); var ex = Assert.Throws<Exception>(() => mapper.Map<CustomType>(dynamicObject)); ex.InnerException.ShouldBeOfType<ArgumentException>(); ex.InnerException.Message.ShouldBe("Object of type 'System.Double' cannot be converted to type 'System.Int32'."); }