public void forward_same_command_to_multiple_different_handlers() { var venga = new Venga(); var command = new FooCommand(); var aFooHandler = new FooHandler(); var anotherFooHandler = new OtherFooHandler(); venga.RegisterHandler(aFooHandler); venga.RegisterHandler(anotherFooHandler); venga.Handle(command); Assert.True(command.WasHandledBy.Any(handler => handler is FooHandler)); Assert.True(command.WasHandledBy.Any(handler => handler is OtherFooHandler)); }
public void forward_command_to_handler() { var command = new FooCommand(); var venga = new Venga(); venga.RegisterHandler(new FooHandler()); venga.Handle(command); Assert.True(command.WasHandled); }
public void forward_command_to_composite_handler() { var barCommand = new BarCommand(); var venga = new Venga(); var handlers = new List <HandleCommand <BarCommand> > { new BarHandler(), new FakeLoggingBarHandler() }; var compositeHandler = new CompositeHandler(handlers); venga.RegisterHandler(compositeHandler); venga.Handle(barCommand); Assert.True(barCommand.WasHandled); Assert.True(barCommand.WasLogged); }