Example #1
0
        public void RaiseErrorWhenMoreThanOneHandler()
        {
            var commandProcessor = new MessageProcessor();
            var fakeCommand      = new FakeCommand();

            Assert.Throws <InvalidOperationException>(() => commandProcessor.Initialize(new[] { typeof(FakeCommandHandler), typeof(OtherFakeCommandHandler), fakeCommand.GetType() }));
        }
Example #2
0
        public void RouteToCommandHandlerWhenPresent()
        {
            var commandProcessor = new MessageProcessor();
            var fakeCommand      = new FakeCommand();

            commandProcessor.Initialize(new[]
            {
                typeof(FakeCommandHandler),
                fakeCommand.GetType()
            });
            commandProcessor.Execute(fakeCommand);
            Assert.IsTrue(fakeCommand.Executed);
        }
Example #3
0
        public void OnTheFlyActionCalled()
        {
            var commandProcessor = new MessageProcessor();

            commandProcessor.Initialize(new[] { typeof(FakeEvent), typeof(FakeCommand), typeof(FakeCommandHandlerRaisingEvent) });
            FakeCommand command = new FakeCommand()
            {
                TestId = 14
            };
            int testId = 0;

            commandProcessor.Observe <FakeEvent>(command, e => testId = e.TestId);
            commandProcessor.Execute(command);
            Assert.AreEqual(command.TestId, testId);
        }