public TestContinuationCommand() { var initializeCommandHanler = new Mock<ICommandHandler<InitializeCommand, IncrementResult>>(); initializeCommandHanler .Setup(ch => ch.Execute(It.IsAny<InitializeCommand>())) .Returns<InitializeCommand>(cmd => new IncrementResult(cmd.InitValue, cmd.Increment)); var incrementCommandHanler = new Mock<ICommandHandler<IncrementCommand, IncrementResult>>(); incrementCommandHanler .Setup(ch => ch.Execute(It.IsAny<IncrementCommand>())) .Returns<IncrementCommand>(cmd => new IncrementResult(cmd.CurrentState + cmd.Increment, cmd.Increment)); _objectMapperMock = new Mock<IObjectMapper>(); _objectMapperMock .Setup(om => om.Map<IncrementResult, IncrementCommand>(It.IsAny<IncrementResult>())) .Returns<IncrementResult>(res => new IncrementCommand(res.Increment, res.Result)); var cmdHandlerFactory = Mock.Of<ICommandHandlerFactory>(chf => chf.Create<InitializeCommand, IncrementResult>() == initializeCommandHanler.Object && chf.Create<IncrementCommand, IncrementResult>() == incrementCommandHanler.Object && chf.Create<MapCommand<IncrementResult, IncrementCommand>, IncrementCommand>() == new MapCommandHandler<IncrementResult, IncrementCommand>(_objectMapperMock.Object) ); _commandHandlerFactoryMock = Mock.Get(cmdHandlerFactory); _commandComposition = new CommandComposition(cmdHandlerFactory, _objectMapperMock.Object); }
public TestContinuationCommand() { var initializeCommandHanler = new Mock <ICommandHandler <InitializeCommand, IncrementResult> >(); initializeCommandHanler .Setup(ch => ch.Execute(It.IsAny <InitializeCommand>())) .Returns <InitializeCommand>(cmd => new IncrementResult(cmd.InitValue, cmd.Increment)); var incrementCommandHanler = new Mock <ICommandHandler <IncrementCommand, IncrementResult> >(); incrementCommandHanler .Setup(ch => ch.Execute(It.IsAny <IncrementCommand>())) .Returns <IncrementCommand>(cmd => new IncrementResult(cmd.CurrentState + cmd.Increment, cmd.Increment)); _objectMapperMock = new Mock <IObjectMapper>(); _objectMapperMock .Setup(om => om.Map <IncrementResult, IncrementCommand>(It.IsAny <IncrementResult>())) .Returns <IncrementResult>(res => new IncrementCommand(res.Increment, res.Result)); var cmdHandlerFactory = Mock.Of <ICommandHandlerFactory>(chf => chf.Create <InitializeCommand, IncrementResult>() == initializeCommandHanler.Object && chf.Create <IncrementCommand, IncrementResult>() == incrementCommandHanler.Object && chf.Create <MapCommand <IncrementResult, IncrementCommand>, IncrementCommand>() == new MapCommandHandler <IncrementResult, IncrementCommand>(_objectMapperMock.Object) ); _commandHandlerFactoryMock = Mock.Get(cmdHandlerFactory); _commandComposition = new CommandComposition(cmdHandlerFactory, _objectMapperMock.Object); }
public IdempotentCommandHandler(ICommandComposition commandComposition) { CommandComposition = commandComposition; }
public ChangeAggregateNameCommandHandler(ICommandComposition commandComposition) : base(commandComposition) { }
protected IdempotentAggregateCommandHandler(ICommandComposition commandComposition) : base(commandComposition) { }
public CreateAggregateCommandHandler(ICommandComposition commandComposition) { _commandComposition = commandComposition; }