public void RaiseErrorWhenMoreThanOneHandler() { var commandProcessor = new MessageProcessor(); var fakeCommand = new FakeCommand(); Assert.Throws <InvalidOperationException>(() => commandProcessor.Initialize(new[] { typeof(FakeCommandHandler), typeof(OtherFakeCommandHandler), fakeCommand.GetType() })); }
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); }
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); }