public void change_multiple_aggregates_test() { var command1 = new CreateTestAggregateCommand { AggregateRootId = ObjectId.GenerateNewStringId(), Title = "Sample Note1" }; _commandService.ExecuteAsync(command1).Wait(); var command2 = new CreateTestAggregateCommand { AggregateRootId = ObjectId.GenerateNewStringId(), Title = "Sample Note2" }; _commandService.ExecuteAsync(command2).Wait(); var command3 = new ChangeMultipleAggregatesCommand { AggregateRootId = ObjectId.GenerateNewStringId(), AggregateRootId1 = command1.AggregateRootId, AggregateRootId2 = command2.AggregateRootId }; var commandResult = _commandService.ExecuteAsync(command3).Result; Assert.IsNotNull(commandResult); Assert.AreEqual(CommandStatus.Failed, commandResult.Status); }
public async Task HandleAsync(ICommandContext context, ChangeMultipleAggregatesCommand command) { var testAggregate1 = await context.GetAsync <TestAggregate>(command.AggregateRootId1); var testAggregate2 = await context.GetAsync <TestAggregate>(command.AggregateRootId2); testAggregate1.TestEvents(); testAggregate2.TestEvents(); }
public void change_multiple_aggregates_test() { var command1 = new CreateTestAggregateCommand { AggregateRootId = ObjectId.GenerateNewStringId(), Title = "Sample Note1" }; _commandService.ExecuteAsync(command1).Wait(); var command2 = new CreateTestAggregateCommand { AggregateRootId = ObjectId.GenerateNewStringId(), Title = "Sample Note2" }; _commandService.ExecuteAsync(command2).Wait(); var command3 = new ChangeMultipleAggregatesCommand { AggregateRootId = ObjectId.GenerateNewStringId(), AggregateRootId1 = command1.AggregateRootId, AggregateRootId2 = command2.AggregateRootId }; var asyncResult = _commandService.ExecuteAsync(command3).Result; Assert.IsNotNull(asyncResult); Assert.AreEqual(AsyncTaskStatus.Success, asyncResult.Status); var commandResult = asyncResult.Data; Assert.IsNotNull(commandResult); Assert.AreEqual(CommandStatus.Failed, commandResult.Status); }
public void Handle(ICommandContext context, ChangeMultipleAggregatesCommand command) { context.Get <TestAggregate>(command.AggregateRootId1).TestEvents(); context.Get <TestAggregate>(command.AggregateRootId2).TestEvents(); }