public override async Task When(ITestHarnessBusFactory busFactory)
        {
            var bus = busFactory.Create();

            var myEvent = new SomeEventThatIsNotReturedByTheTypeProvider();
            await bus.Publish(myEvent);
        }
        public async Task TheExceptionShouldContainTheMessageThatWasThrownOnTheServer(ITestHarnessBusFactory busFactory)
        {
            await Given(busFactory);
            await When();

            _exception.Message.ShouldContain(RequestThatWillThrowHandler.ExceptionMessage);
        }
        public async Task WeShouldReceiveThreeResponses(ITestHarnessBusFactory busFactory)
        {
            await Given(busFactory);
            await When();

            _response.Count().ShouldBe(3);
        }
示例#4
0
        public virtual async Task Given(ITestHarnessBusFactory busFactory)
        {
            Bus = (Bus) busFactory.Create();

            Console.WriteLine();
            Console.WriteLine();
        }
        public async Task AnExceptionShouldBeReThrownOnTheClient(ITestHarnessBusFactory busFactory)
        {
            await Given(busFactory);
            await When();

            _exception.ShouldNotBe(null);
        }
        public async Task TheExceptionShouldBeARequestFailedException(ITestHarnessBusFactory busFactory)
        {
            await Given(busFactory);
            await When();

            _exception.ShouldBeTypeOf<RequestFailedException>();
        }
        public override Task Given(ITestHarnessBusFactory busFactory)
        {
            _response = null;
            _exception = null;

            return base.Given(busFactory);
        }
        public async Task TheResponseShouldNotBeSet(ITestHarnessBusFactory busFactory)
        {
            await Given(busFactory);
            await When();

            _response.ShouldBe(null);
        }
        public override async Task When(ITestHarnessBusFactory busFactory)
        {
            var bus = busFactory.Create();

            var myCommand = new SomeCommandThatIsNotReturedByTheTypeProvider();
            await bus.Send(myCommand);
        }
        public async void ThereShouldBeExactlyOneMessageOnTheDeadLetterQueue(ITestHarnessBusFactory busFactory)
        {
            await When(busFactory);

            _deadLetterMessages.Count.ShouldBe(1);
            _deadLetterMessages.Single().SomeContent.ShouldBe(_someContent);
        }
        public async Task TheCommandBrokerShouldReceiveThatCommand(ITestHarnessBusFactory busFactory)
        {
            await Given(busFactory);
            await When();

            MethodCallCounter.AllReceivedMessages.OfType<SomeCommand>().Count().ShouldBe(1);
        }
        public override async Task When(ITestHarnessBusFactory busFactory)
        {
            var bus = busFactory.Create();

            var myEvent = new SomeEventWeDoNotHandle();
            await bus.Publish(myEvent);
        }
        public async Task TheCorrectNumberOfTotalMessagesShouldHaveBeenObserved(ITestHarnessBusFactory busFactory)
        {
            await Given(busFactory);
            await When();

            MethodCallCounter.AllReceivedMessages.Count().ShouldBe(1);
        }
        public async Task WeShouldGetSomethingNiceBack(ITestHarnessBusFactory busFactory)
        {
            await Given(busFactory);
            await When();

            _response.ShouldNotBe(null);
        }
        public override async Task When(ITestHarnessBusFactory busFactory)
        {
            var bus = busFactory.Create();

            await bus.Publish(new SomeEventWeHandleViaMulticastAndCompetition());

            TimeSpan.FromSeconds(5).SleepUntil(() => MethodCallCounter.AllReceivedMessages.Count() >= 2);
        }
        public async void TheMulticastEventBrokerShouldReceiveTheEvent(ITestHarnessBusFactory busFactory)
        {
            await When(busFactory);

            MethodCallCounter.ReceivedCallsWithAnyArg<SomeMulticastEventHandler>(mb => mb.Handle((SomeEventWeOnlyHandleViaMulticast) null))
                             .Count()
                             .ShouldBe(1);
        }
        public override async Task When(ITestHarnessBusFactory busFactory)
        {
            var bus = busFactory.Create();

            var someCommand = new SomeCommand();
            await bus.Send(someCommand);
            TimeSpan.FromSeconds(5).SleepUntil(() => MethodCallCounter.AllReceivedMessages.Any());
        }
        public async Task TheMulticastEventBrokerShouldReceiveTheEvent(ITestHarnessBusFactory busFactory)
        {
            await Given(busFactory);
            await When();

            MethodCallCounter.ReceivedCallsWithAnyArg<SomeMulticastEventHandler>(mb => mb.Handle((SomeEventWeHandleViaMulticastAndCompetition) null))
                             .Count()
                             .ShouldBe(1);
        }
        public override async Task When(ITestHarnessBusFactory busFactory)
        {
            var bus = busFactory.Create();

            var myEvent = new SomeEventWeOnlyHandleViaMulticast();
            await bus.Publish(myEvent);

            TimeSpan.FromSeconds(5).SleepUntil(() => MethodCallCounter.AllReceivedMessages.Any());
        }
        public async void TheCorrectNumberOfEventsOfThisTypeShouldHaveBeenObserved(ITestHarnessBusFactory busFactory)
        {
            await When(busFactory);

            MethodCallCounter.AllReceivedMessages
                             .OfType<SomeEventWeOnlyHandleViaMulticast>()
                             .Count()
                             .ShouldBe(1);
        }
        public async Task TheCorrectNumberOfEventsOfThisTypeShouldHaveBeenObserved(ITestHarnessBusFactory busFactory)
        {
            await Given(busFactory);
            await When();

            MethodCallCounter.AllReceivedMessages
                             .OfType<SomeEventWeHandleViaMulticastAndCompetition>()
                             .Count()
                             .ShouldBe(2);
        }
        public override async Task When(ITestHarnessBusFactory busFactory)
        {
            var bus = busFactory.Create();

            var request = new BlackBallRequest
                          {
                              ProspectiveMemberName = "Fred Flintstone",
                          };

            _response = await bus.MulticastRequest(request, TimeSpan.FromSeconds(2));
        }
        public override async Task When(ITestHarnessBusFactory busFactory)
        {
            var bus = busFactory.Create();

            _someContent = Guid.NewGuid().ToString();
            _testCommand = new TestCommand(_someContent);

            await bus.Send(_testCommand);
            TimeSpan.FromSeconds(10).SleepUntil(() => MethodCallCounter.AllReceivedCalls.Count() >= _maxDeliveryAttempts);

            _deadLetterMessages = await FetchAllDeadLetterMessages(bus);
        }
 public async void ABusExceptionIsThrown(ITestHarnessBusFactory busFactory)
 {
     try
     {
         await When(busFactory);
         Assert.Fail("Exception expected");
     }
     catch (Exception ex)
     {
         ex.ShouldBeTypeOf<BusException>();
         ex.Message.ShouldMatch(
             @"^The type Nimbus.IntegrationTests.Tests.SimpleCommandSendingTests.MessageContracts.SomeCommandThatIsNotReturedByTheTypeProvider is not a recognised command type\. Ensure it has been registered with the builder with the WithTypesFrom method\.$");
     }
 }
        public async Task ABusExceptionIsThrown(ITestHarnessBusFactory busFactory)
        {
            await Given(busFactory);

            try
            {
                await When();
                Assert.Fail("Exception expected");
            }
            catch (Exception ex)
            {
                ex.ShouldBeTypeOf<BusException>();
                ex.Message.ShouldMatch(
                    @"^The type Nimbus.IntegrationTests.Tests.MulticastRequestResponseTests.MessageContracts.SomeRequestThatIsNotReturedByTheTypeProvider is not a recognised request type\. Ensure it has been registered with the builder with the WithTypesFrom method\.$");
            }
        }
        public override async Task When(ITestHarnessBusFactory busFactory)
        {
            _response = null;
            _exception = null;

            var bus = busFactory.Create();

            try
            {
                var request = new RequestThatWillThrow();
                _response = await bus.Request(request);
            }
            catch (RequestFailedException exc)
            {
                _exception = exc;
            }
        }
 public void NoExceptionIsThrown(ITestHarnessBusFactory busFactory)
 {
     Should.NotThrow(async () => await When(busFactory));
 }
 public async Task NothingShouldGoBang(ITestHarnessBusFactory busFactory)
 {
     await Given(busFactory);
     await When();
 }
 public async Task NoExceptionIsThrown(ITestHarnessBusFactory busFactory)
 {
     await Given(busFactory);
     Should.NotThrow(async () => await When());
 }
示例#30
0
 public abstract Task When(ITestHarnessBusFactory busFactory);