Пример #1
0
		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);
		}
Пример #2
0
        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);
        }
Пример #3
0
		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);
		}
Пример #4
0
		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);
		}
Пример #5
0
        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);
        }