public async Task When_one_of_two_aggregate_throws_fault_not_received_expected_messages_are_ignored()
        {
            var syncCommand = new CreateAndChangeSampleAggregateCommand(100, Guid.NewGuid());
            var messages    = new ExpectedMessage[]
            {
                Expect.Fault <SampleAggregateCreatedEvent>(e => e.SourceId, syncCommand.AggregateId),
                Expect.Fault <SampleAggregateChangedEvent>(e => e.SourceId, syncCommand.AggregateId),
                Expect.Message <AggregateChangedEventNotification>(e => e.AggregateId, syncCommand.AggregateId),
                Expect.Message <AggregateCreatedEventNotification>(e => e.AggregateId, syncCommand.AggregateId)
            };

            try
            {
                await GridNode.Execute(new CommandPlan(syncCommand, messages));

                Assert.Fail("Wait ended after one of two notifications");
            }
            catch (AggregateException ex)
            {
                var exception = ex.UnwrapSingle();

                if (exception is SampleAggregateException)
                {
                    Assert.Pass("Got exception from create message handler");
                }
                if (exception is MessageHandleException)
                {
                    Assert.Pass("Got exception from change message handler");
                }
                Assert.Fail($"Unknown exception type: {exception.GetType()}");
            }
        }
示例#2
0
        public void When_expect_more_than_one_messages()
        {
            var cmd = new CreateAndChangeSampleAggregateCommand(100, Guid.NewGuid());

            _results = GridNode.NewCommandWaiter(Timeout)
                       .Expect <SampleAggregateChangedEvent>(e => e.SourceId == cmd.AggregateId)
                       .And <SampleAggregateCreatedEvent>(e => e.SourceId == cmd.AggregateId)
                       .Create()
                       .Execute(cmd).Result;
        }
示例#3
0
        public void When_expect_more_than_one_messages()
        {
            var syncCommand = new CreateAndChangeSampleAggregateCommand(100, Guid.NewGuid());
            var messages    = new ExpectedMessage[]
            {
                Expect.Message <SampleAggregateChangedEvent>(e => e.SourceId, syncCommand.AggregateId),
                Expect.Message <SampleAggregateCreatedEvent>(e => e.SourceId, syncCommand.AggregateId)
            };

            _anObject = GridNode.Execute(new CommandPlan(syncCommand, messages)).Result as object[]; //to array
        }