public void Engine_Deals_With_Duplicate_Mappings() { var frameworkContext = new FakeFrameworkContext(); var engine = new FakeMappingEngine(frameworkContext); //create duplicate mappings...though only the first will be added and no exception thrown engine.CreateMap <FakeMappingEngine, FakeMappingEngine>(); Assert.Throws <InvalidOperationException>(() => engine.CreateMap <FakeMappingEngine, FakeMappingEngine>()); }
public void Map_To_Type_From_Super_Type() { _mappingEngine.CreateMap <Foo, Bar>(true); var inheritedMap = _mappingEngine.GetMapperDefinition(typeof(SuperFoo), typeof(Bar), false); Assert.IsNotNull(inheritedMap); Assert.DoesNotThrow(() => _mappingEngine.Map <Bar>(new SuperFoo())); _mappingEngine.ClearMappers(); _mappingEngine.CreateMap <Foo, Bar>(false); Assert.Throws <NotSupportedException>(() => _mappingEngine.GetMapperDefinition(typeof(SuperFoo), typeof(Bar), false)); }