public async Task Wait_for_timeout_command_throws_excpetion() { var cmd = new PlanTitleWriteCommand(1000, Guid.NewGuid()); await Node.Prepare(cmd) .Expect <BalloonTitleChanged>(e => e.SourceId == cmd.AggregateId) .Execute(TimeSpan.FromMilliseconds(100)) .ShouldThrow <TimeoutException>(); }
public async Task When_does_not_expect_fault_and_it_accures_wait_times_out() { var syncCommand = new PlanTitleWriteCommand(100, Guid.NewGuid()); await Node.Prepare(syncCommand) .Expect <BalloonTitleChangedNotification>(e => e.BallonId == syncCommand.AggregateId) .Execute(TimeSpan.FromMilliseconds(50)) .ShouldThrow <TimeoutException>(); }
public void CommandWaiter_doesnt_throw_exception_after_wait_with_timeout() { var syncCommand = new PlanTitleWriteCommand(1000, Guid.NewGuid()); Node.Prepare(syncCommand) .Expect <BalloonTitleChanged>(e => e.SourceId == syncCommand.AggregateId) .Execute(TimeSpan.FromMilliseconds(500)) .Wait(100); }
public async Task CommandWaiter_throws_exception_after_wait_with_only_default_timeout() { var syncCommand = new PlanTitleWriteCommand(1000, Guid.NewGuid().ToString()); var waiter = Node.Prepare(syncCommand) .Expect <BalloonTitleChanged>(e => e.SourceId == syncCommand.AggregateId) .Execute(TimeSpan.FromMilliseconds(100)); await Assert.ThrowsAsync <TimeoutException>(() => waiter); }
public async Task When_expect_fault_and_ignore_fault_errors_Then_fault_is_received_and_contains_error_B() { var syncCommand = new PlanTitleWriteCommand(100, Guid.NewGuid()); var res = await Node.Prepare(syncCommand) .Expect <BalloonTitleChangedNotification>() .Or <Fault <BalloonTitleChanged> >(f => f.Message.SourceId == syncCommand.AggregateId) .Execute(false); Assert.IsAssignableFrom <MessageHandleException>(res.Message <IFault <BalloonTitleChanged> >()?.Exception); }
public async Task PlanExecute_by_result_throws_exception_after_default_timeout() { var syncCommand = new PlanTitleWriteCommand(1000, Guid.NewGuid()); await Node.Prepare(syncCommand) .Expect <BalloonTitleChanged>() .Execute(TimeSpan.FromMilliseconds(500)) .ShouldThrow <TimeoutException>(); }
public async Task CommandWaiter_will_wait_for_all_of_expected_message() { var cmd = new PlanTitleWriteCommand(1000, Guid.NewGuid()); await Node.Prepare(cmd) .Expect <BalloonTitleChanged>(e => e.SourceId == cmd.AggregateId) .And <BalloonCreated>(e => e.SourceId == cmd.AggregateId) .Execute() .ShouldThrow <TimeoutException>(); }
public async Task Sync_method_should_change_aggregate() { var syncCommand = new PlanTitleWriteCommand(42, Guid.NewGuid()); await Node.Prepare(syncCommand).Expect <BalloonTitleChanged>().Execute(); //to finish persistence var aggregate = await this.LoadAggregateByActor <Balloon>(syncCommand.AggregateId); Assert.Equal(syncCommand.Parameter.ToString(), aggregate.Title); }
public async Task Aggregate_will_apply_events_later_than_command_execution_finish() { var syncCommand = new PlanTitleWriteCommand(42, Guid.NewGuid()); #pragma warning disable 4014 Node.Execute(syncCommand); #pragma warning restore 4014 var aggregate = await this.LoadAggregateByActor <Balloon>(syncCommand.AggregateId); Assert.NotEqual(syncCommand.Parameter.ToString(), aggregate.Title); }
public async Task When_expected_optional_fault_does_not_occur_wait_is_successfull() { var syncCommand = new PlanTitleWriteCommand(101, Guid.NewGuid()); var res = await Node.Prepare(syncCommand) .Expect <BalloonTitleChangedNotification>(e => e.BallonId == syncCommand.AggregateId) .Or <Fault>(f => (f.Message as DomainEvent)?.SourceId == syncCommand.AggregateId) .Execute(); var evt = res.Message <BalloonTitleChangedNotification>(); Assert.Equal(syncCommand.AggregateId, evt.BallonId); }
public async Task CommandWaiter_Should_wait_until_aggregate_event() { var cmd = new PlanTitleWriteCommand(100, Guid.NewGuid()); var res = await Node.Prepare(cmd) .Expect <BalloonTitleChanged>(e => e.SourceId == cmd.AggregateId) .Execute(); var msg = res.Message <BalloonTitleChanged>(); Assert.Equal(cmd.Parameter.ToString(), msg.Value); }
public async Task MessageWaiter_after_cmd_execute_should_waits_until_aggregate_event() { var cmd = new PlanTitleWriteCommand(100, Guid.NewGuid()); var waiter = Node.NewExplicitWaiter() .Expect <MessageMetadataEnvelop>(e => (e.Message as BalloonTitleChanged)?.SourceId == cmd.AggregateId) .Create(); await Node.Execute(cmd); var res = await waiter; Assert.Equal(cmd.Parameter.ToString(), res.Message <BalloonTitleChanged>().Value); }
public async Task Default_wait_for_event_matches_by_correlation_id_when_projection_builder_cares_about_metadata() { var commandA = new PlanTitleWriteCommand(10, Guid.NewGuid().ToString()); var commandB = new PlanTitleWriteCommand(10, Guid.NewGuid().ToString()); await Node.Execute(commandB); var res = await Node.Prepare(commandA) .Expect <BalloonTitleChangedNotification>() .Execute(false); //will pick right command by correlation Id Assert.Equal(commandA.AggregateId, res.Message <BalloonTitleChangedNotification>().BallonId); }
public async Task Given_command_executes_with_waiter_When_fetching_results() { var syncCommand = new PlanTitleWriteCommand(1000, Guid.NewGuid()); var results = await Node.Prepare(syncCommand) .Expect <BalloonTitleChangedNotification>() .Execute(); var changedEvent = results.Received; var aggregate = await this.LoadAggregateByActor <Balloon>(syncCommand.AggregateId); //Results_contains_received_messages() Assert.NotEmpty(results.All); //Results_contains_requested_message() Assert.NotNull(changedEvent); //Emmited_event_has_correct_id() Assert.Equal(syncCommand.AggregateId, changedEvent?.BallonId); //Aggregate_has_correct_state_from_command() Assert.Equal(syncCommand.Parameter.ToString(), aggregate.Title); }
public async Task Sync_method_should_produce_messages_for_projection_builders() { var cmd = new PlanTitleWriteCommand(42, Guid.NewGuid()); await Node.Prepare(cmd).Expect <BalloonTitleChangedNotification>().Execute(); }