public async Task Peek_when_timeout_exists_should_return_timeout()
        {
            var persister    = new InMemoryTimeoutPersister(() => DateTime.UtcNow);
            var inputTimeout = new TimeoutData();
            await persister.Add(inputTimeout, new ContextBag());

            var result = await persister.Peek(inputTimeout.Id, new ContextBag());

            Assert.AreSame(inputTimeout, result);
        }
        public async Task Peek_when_timeout_does_not_exist_should_return_null()
        {
            var persister    = new InMemoryTimeoutPersister(() => DateTime.UtcNow);
            var inputTimeout = new TimeoutData();
            await persister.Add(inputTimeout, new ContextBag());

            var result = await persister.Peek(Guid.NewGuid().ToString(), new ContextBag());

            Assert.IsNull(result);
        }
        public async Task Invoke_when_dispatching_message_fails_should_keep_timeout_in_storage()
        {
            var messageDispatcher = new FailingMessageDispatcher();
            var timeoutPersister = new InMemoryTimeoutPersister(() => DateTime.UtcNow);
            var behavior = new DispatchTimeoutBehavior(messageDispatcher, timeoutPersister, TransportTransactionMode.TransactionScope);
            var timeoutData = CreateTimeout();
            await timeoutPersister.Add(timeoutData, null);

            Assert.That(async () => await behavior.Invoke(CreateContext(timeoutData.Id)), Throws.InstanceOf<Exception>());

            var result = await timeoutPersister.Peek(timeoutData.Id, null);
            Assert.NotNull(result);
        }
        public async Task Invoke_when_message_dispatched_should_remove_timeout_from_timeout_storage()
        {
            var messageDispatcher = new FakeMessageDispatcher();
            var timeoutPersister = new InMemoryTimeoutPersister(() => DateTime.UtcNow);
            var behavior = new DispatchTimeoutBehavior(messageDispatcher, timeoutPersister, TransportTransactionMode.TransactionScope);
            var timeoutData = CreateTimeout();
            await timeoutPersister.Add(timeoutData, null);

            await behavior.Invoke(CreateContext(timeoutData.Id));

            var result = await timeoutPersister.Peek(timeoutData.Id, null);
            Assert.Null(result);
        }
예제 #5
0
        public async Task Invoke_when_dispatching_message_fails_should_keep_timeout_in_storage()
        {
            var messageDispatcher = new FailingMessageDispatcher();
            var timeoutPersister  = new InMemoryTimeoutPersister(() => DateTime.UtcNow);
            var behavior          = new DispatchTimeoutBehavior(messageDispatcher, timeoutPersister, TransportTransactionMode.TransactionScope);
            var timeoutData       = CreateTimeout();
            await timeoutPersister.Add(timeoutData, null);

            Assert.That(async() => await behavior.Invoke(CreateContext(timeoutData.Id)), Throws.InstanceOf <Exception>());

            var result = await timeoutPersister.Peek(timeoutData.Id, null);

            Assert.NotNull(result);
        }
예제 #6
0
        public async Task Invoke_when_message_dispatched_should_remove_timeout_from_timeout_storage()
        {
            var messageDispatcher = new FakeMessageDispatcher();
            var timeoutPersister  = new InMemoryTimeoutPersister(() => DateTime.UtcNow);
            var behavior          = new DispatchTimeoutBehavior(messageDispatcher, timeoutPersister, TransportTransactionMode.TransactionScope);
            var timeoutData       = CreateTimeout();
            await timeoutPersister.Add(timeoutData, null);

            await behavior.Invoke(CreateContext(timeoutData.Id));

            var result = await timeoutPersister.Peek(timeoutData.Id, null);

            Assert.Null(result);
        }
        public async Task Peek_when_timeout_exists_should_return_timeout()
        {
            var persister = new InMemoryTimeoutPersister(() => DateTime.UtcNow);
            var inputTimeout = new TimeoutData();
            await persister.Add(inputTimeout, new ContextBag());

            var result = await persister.Peek(inputTimeout.Id, new ContextBag());

            Assert.AreSame(inputTimeout, result);
        }
        public async Task Peek_when_timeout_does_not_exist_should_return_null()
        {
            var persister = new InMemoryTimeoutPersister(() => DateTime.UtcNow);
            var inputTimeout = new TimeoutData();
            await persister.Add(inputTimeout, new ContextBag());

            var result = await persister.Peek(Guid.NewGuid().ToString(), new ContextBag());

            Assert.IsNull(result);
        }