public void CanPreventMoreThanOneSubscriberRegisteredPerCommand()
        {
            var commands = new CommandSubscribers();

            _bus.RegisterSubscriptionFor <TestCommand>(commands.Handle);
            _bus.RegisterSubscriptionFor <TestCommand>(commands.Handle);

            Assert.ThrowsAsync <DuplicateSubscriberRegisteredException>(async() => await _bus.Send(new TestCommand(string.Empty)));
        }
        public async Task SubscriberCanProcessMessageOnCommandSend()
        {
            const string expectedPayload = "payload";

            var commands = new CommandSubscribers();

            _bus.RegisterSubscriptionFor <TestCommand>(commands.Handle);

            await _bus.Send(new TestCommand(expectedPayload));

            Assert.That(commands.ProcessedMessagePayload, Is.EqualTo(expectedPayload));
        }
Exemplo n.º 3
0
            public async Task SetUp()
            {
                await ClearAllDataFiles();

                var retryPolicy = new RetryPolicy(1, DateTimeUtility.PositiveOneHourTimeSpan);

                _bus = new DurableMessageBus(retryPolicy);

                _commands = new CommandSubscribers();
                _events   = new EventSubscribers();
                _bus.RegisterSubscriptionFor <TestDurableCommand>(_commands.Handle);
                _bus.RegisterSubscriptionFor <TestDurableEvent>(_events.Handle);
            }
Exemplo n.º 4
0
            public async Task SetUp()
            {
                await ClearAllDataFiles();

                var retryPolicy = new RetryPolicy();

                Assume.That(retryPolicy.Retries, Is.EqualTo(0));

                _bus = new DurableMessageBus(retryPolicy);

                _commands = new CommandSubscribers();
                _events   = new EventSubscribers();
                _bus.RegisterSubscriptionFor <TestDurableCommand>(_commands.Handle);
                _bus.RegisterSubscriptionFor <TestDurableEvent>(_events.Handle);
            }
Exemplo n.º 5
0
            public async Task MessageIsNotSendToSubscriberOnStart()
            {
                const string singleValue = "0";

                //we need a retry policy with at least one retry
                //  so that we'd expect the call to Start() to attempt a retry
                var retryPolicy = new RetryPolicy(1, DateTimeUtility.PositiveOneHourTimeSpan);

                var bus      = new DurableMessageBus(retryPolicy);
                var commands = new CommandSubscribers();

                bus.RegisterSubscriptionFor <TestDurableCommand>(commands.Handle);

                await bus.SendDurable(new TestDurableCommand(singleValue));

                Assume.That(commands.ProcessedMessagePayload, Is.EqualTo(singleValue), "Command Subscriber didn't receive the expected message.");

                bus.UnRegisterAllSubscriptionsFor <TestDurableCommand>();

                await bus.Start();

                Assert.That(commands.ProcessedMessagePayload, Is.EqualTo(singleValue), "Bus did not properly ignore queued command.");
            }