protected override async Task When()
        {
            await Subject.Send(new FooCommand());

            await Timeout.WaitUntil(() => MethodCallCounter.TotalReceivedCalls >= _expectedTotalCallCount);

            MethodCallCounter.Stop();
            MethodCallCounter.Dump();
        }
        protected override async Task When()
        {
            MethodCallCounter.Clear();

            var command1 = new FooCommand(_id1);
            var command2 = new FooCommand(_id2);

            await Subject.Dispatch(await _brokeredMessageFactory.Create(command1));

            await Subject.Dispatch(await _brokeredMessageFactory.Create(command2));

            MethodCallCounter.Stop();
        }
        protected override async Task When()
        {
            await Task.WhenAll(
                Subject.Send(new SomeCommand(42)),
                Subject.SendAt(new SomeCommandSentViaDelay(), DateTimeOffset.UtcNow),
                Subject.Request(new SomeRequest()),
                Subject.MulticastRequest(new SomeMulticastRequest(), TimeSpan.FromSeconds(1)),
                Subject.Publish(new SomeEvent())
                );

            await TimeSpan.FromSeconds(_timeoutSeconds).WaitUntil(() => MethodCallCounter.AllReceivedMessages.Count() >= 7);

            MethodCallCounter.Stop();

            _allAuditedMessages = MethodCallCounter.AllReceivedMessages
                                  .OfType <AuditEvent>()
                                  .Select(ae => ae.MessageBody)
                                  .ToArray();
        }
        protected override async Task When()
        {
            Enumerable.Range(0, _totalCommands)
            .Select(i => Bus.Send(new SlowCommand()))
            .WaitAll();
            await Task.Delay(TimeSpan.FromMilliseconds(500));

            await Bus.Stop();

            _commandHandlerInvocationCount = MethodCallCounter.AllReceivedMessages.OfType <SlowCommand>().Count();
            Console.WriteLine("Bus has stopped.");
            Console.WriteLine("Number of commands received immediately afterwards: {0}", _commandHandlerInvocationCount);
            MethodCallCounter.Clear();

            await Task.Delay(TimeSpan.FromSeconds(2));

            _additionalCommandHandlerInvocationCount = MethodCallCounter.AllReceivedMessages.OfType <SlowCommand>().Count();
            Console.WriteLine("Number of commands received after that: {0}", _additionalCommandHandlerInvocationCount);
            MethodCallCounter.Stop();
        }
Exemple #5
0
        public void TestFixtureSetUp()
        {
            Task.Run(async() =>
            {
                MethodCallCounter.Clear();

                Bus = await new TestHarnessBusFactory(GetType()).CreateAndStart();
                Console.WriteLine();
                Console.WriteLine();

                await Given();
                Console.WriteLine();
                Console.WriteLine();

                await When();
                MethodCallCounter.Stop();
                Console.WriteLine();
                Console.WriteLine();
            }).Wait();
        }