public void TestPipelineDataaIsNullThrowsException() { var registry = new MapperRegistry(); registry.Add(new FakeMap()); var map = registry.Get<ICommandMetadata, IInputModel>(); Assert.NotNull(map); var step = new GetInputModelStep(registry); var data = step.Execute(null); }
public void TestRegistry() { //Arrange var mockMap = new Mock<IMapper<int, string>>(); mockMap.Setup(m => m.Source).Returns(typeof (int)); mockMap.Setup(m => m.Destination).Returns(typeof (string)); var registry = new MapperRegistry(); registry.Add(mockMap.Object); var map = registry.Get<int, string>(); Assert.NotNull(map); }
public void TestPipelineDataContainsNullValue() { var registry = new MapperRegistry(); registry.Add(new FakeMap()); var map = registry.Get<ICommandMetadata, IInputModel>(); Assert.NotNull(map); var data = new MapCommandPipelineData { CommandMetadata = null }; var step = new GetInputModelStep(registry); data = step.Execute(data); }
public void TestMetadataToInputModelStep() { var registry = new MapperRegistry(); registry.Add(new FakeMap()); var map = registry.Get<ICommandMetadata, IInputModel>(); Assert.NotNull(map); var data = new MapCommandPipelineData { CommandMetadata = new Mock<ICommandMetadata>().Object }; var step = new GetInputModelStep(registry); data = step.Execute(data); Assert.NotNull(data.InputModel); }
private IMapper CreateMap(Type fromType, Type toType, string key) { IMapper mapper = null; foreach (var fac in FactoryRegistry) { if (fac.IsMatch(fromType, toType)) { mapper = CreateGenericMapper(fromType, toType, fac); MapperRegistry.Add(key, mapper); break; } } if (mapper == null) { throw new NotSupportedException("Mapper does not support " + key + "."); } return(mapper); }