public void The_message_processor_should_process_this_message()
        {
            //Application Startup code
            var configuration = new CommandEngineConfiguration();

            configuration.Initialize(typeof(MessageProcessorTester).Assembly);

            var locator = S <IServiceLocator>();

            locator.Stub(ioC => ioC.GetAllInstances(null)).IgnoreArguments().Return(new[] { new TestMessageCommandHandler() });
            ServiceLocator.SetLocatorProvider(() => locator);

            //request startup code.
            var invoker    = new CommandInvoker(new ValidationEngine(new ValidationRuleFactory()), new CommandFactory());
            var unitOfWork = S <IUnitOfWork>();
            var mapper     = S <IMessageMapper>();

            mapper.Stub(messageMapper => messageMapper.MapUiMessageToCommandMessage(null, null, null)).IgnoreArguments().Return(
                new TestCommandMessage());
            var processor = new MessageProcessor(mapper, invoker, unitOfWork, configuration);

            ExecutionResult result = processor.Process(new TestViewModel {
                Message = "foo"
            }, typeof(TestViewModel));

            Assert.True(result.Successful);
            Assert.AreEqual(0, result.Messages.Count());
            Assert.NotNull(result.ReturnItems.Get <TestCommandMessage>());
        }
Beispiel #2
0
 public void Initialize(Assembly assembly, IMessageMapper messageMapper)
 {
     if (_mappingEngine == null)
     {
         lock (_lock)
         {
             if (_configuration == null)
             {
                 Configuration = new CommandEngineConfiguration();
                 Configuration.Initialize(assembly);
                 _mappingEngine = messageMapper;
             }
         }
     }
 }