示例#1
0
        public void AddTwoDifferentTimeouts(
            MongoTimeoutPersister sut,
            MongoDatabaseFactory factory,
            Timeout.Core.TimeoutData timeout1,
            Timeout.Core.TimeoutData timeout2)
        {
            factory.ResetTimeoutCollection();

            sut.Add(timeout1);
            sut.Add(timeout2);

            var result = factory.RetrieveAllTimeouts();

            result.Should().HaveCount(2);
        }
示例#2
0
        public void GetNextChunkReturnsEmptyListWhenCollectionHasTwoTimeoutsAfterUtcNow(
            MongoTimeoutPersister sut,
            MongoDatabaseFactory factory,
            Timeout.Core.TimeoutData timeoutData)
        {
            factory.ResetTimeoutCollection();

            timeoutData.Time = DateTime.UtcNow.AddMinutes(1);
            sut.Add(timeoutData);
            sut.Add(timeoutData);

            var      startSlice = DateTime.UtcNow.AddMinutes(-5);
            DateTime nextTimeToRunQuery;
            var      result = sut.GetNextChunk(startSlice, out nextTimeToRunQuery);

            result.Should().HaveCount(0);
            nextTimeToRunQuery.Should().Be(timeoutData.Time);
        }
示例#3
0
        public void RemoveTimeoutByIdRemovesCorrectTimeoutAndDoesNotRemoveOtherTimeout(
            MongoTimeoutPersister sut,
            MongoDatabaseFactory factory,
            Timeout.Core.TimeoutData timeoutData1,
            Timeout.Core.TimeoutData timeoutData2)
        {
            factory.ResetTimeoutCollection();

            sut.Add(timeoutData1);
            sut.Add(timeoutData2);

            sut.RemoveTimeoutBy(timeoutData2.SagaId);

            var remainingTimeouts = factory.RetrieveAllTimeouts().ToList();

            remainingTimeouts.Should().HaveCount(1);

            remainingTimeouts.First().SagaId.Should().Be(timeoutData1.SagaId);
        }
        public void GetNextChunkReturnsOneTimeoutWhenCollectionHasOneTimeoutBetweenStartSliceAndUtcNowAndOneAfterUtcNow(
            MongoTimeoutPersister sut,
            MongoDatabaseFactory factory,
            Timeout.Core.TimeoutData timeoutData1,
            Timeout.Core.TimeoutData timeoutData2,
            ContextBag context)
        {
            factory.ResetTimeoutCollection();

            timeoutData1.Time = DateTime.UtcNow.AddMinutes(-1);
            sut.Add(timeoutData1, context).Wait();
            timeoutData2.Time = DateTime.UtcNow.AddMinutes(1);
            sut.Add(timeoutData2, context).Wait();

            var startSlice = DateTime.UtcNow.AddMinutes(-5);
            var result     = sut.GetNextChunk(startSlice).Result;

            result.DueTimeouts.Should().HaveCount(1);
            result.NextTimeToQuery.Should().BeOnOrBefore(timeoutData2.Time);
        }
示例#5
0
        public void RemoveTimeoutByIdOnNonExistantIdDoesNotRemoveOtherTimeout(
            MongoTimeoutPersister sut,
            MongoDatabaseFactory factory,
            Timeout.Core.TimeoutData timeoutData)
        {
            factory.ResetTimeoutCollection();

            sut.Add(timeoutData);

            sut.RemoveTimeoutBy(Guid.NewGuid());

            factory.RetrieveAllTimeouts().Should().HaveCount(1);
        }
示例#6
0
        public void RemoveTimeoutByIdRemovesTimeout(
            MongoTimeoutPersister sut,
            MongoDatabaseFactory factory,
            Timeout.Core.TimeoutData timeoutData)
        {
            factory.ResetTimeoutCollection();

            sut.Add(timeoutData);

            sut.RemoveTimeoutBy(timeoutData.SagaId);

            factory.RetrieveAllTimeouts().Should().HaveCount(0);
        }
        public void TryRemoveShouldSucceedAndReturnDataForOneTimeoutAndLeaveTheOther(
            MongoTimeoutPersister sut,
            MongoDatabaseFactory factory,
            Timeout.Core.TimeoutData timeoutData1,
            Timeout.Core.TimeoutData timeoutData2,
            ContextBag context)
        {
            factory.ResetTimeoutCollection();

            sut.Add(timeoutData1, context).Wait();
            sut.Add(timeoutData2, context).Wait();

            var timeouts = factory.RetrieveAllTimeouts();

            var result = sut.TryRemove(timeouts.First().Id, context).Result;

            result.Should().BeTrue();

            var remainingTimeout = factory.RetrieveAllTimeouts().ToList();

            remainingTimeout.Should().HaveCount(1);
            remainingTimeout.First().Id.Should().Be(timeouts.Last().Id);
        }
        public void AddOneTimeout(
            MongoTimeoutPersister sut,
            MongoDatabaseFactory factory,
            Timeout.Core.TimeoutData timeoutData,
            ContextBag context)
        {
            factory.ResetTimeoutCollection();

            sut.Add(timeoutData, context).Wait();

            var result = factory.RetrieveAllTimeouts();

            result.Should().HaveCount(1);
        }
示例#9
0
        public void TryRemoveShouldSucceedAndReturnDataForOneTimeoutAndLeaveTheOther(
            MongoTimeoutPersister sut,
            MongoDatabaseFactory factory,
            Timeout.Core.TimeoutData timeoutData1,
            Timeout.Core.TimeoutData timeoutData2)
        {
            factory.ResetTimeoutCollection();

            sut.Add(timeoutData1);
            sut.Add(timeoutData2);
            Timeout.Core.TimeoutData returnedTimeoutData;

            var timeouts = factory.RetrieveAllTimeouts();

            var result = sut.TryRemove(timeouts.First().Id.ToString(), out returnedTimeoutData);

            result.Should().BeTrue();
            returnedTimeoutData.ShouldBeEquivalentTo(timeoutData1);

            var remainingTimeout = factory.RetrieveAllTimeouts().ToList();

            remainingTimeout.Should().HaveCount(1);
            remainingTimeout.First().ShouldBeEquivalentTo(timeoutData2);
        }
        public void PeekExistingTimeout(
            MongoTimeoutPersister sut,
            MongoDatabaseFactory factory,
            Timeout.Core.TimeoutData timeout1,
            ContextBag context)
        {
            factory.ResetTimeoutCollection();

            sut.Add(timeout1, context).Wait();
            var result = factory.RetrieveAllTimeouts().First();

            var peeked = sut.Peek(result.Id, context).Result;

            peeked.SagaId.Should().Be(timeout1.SagaId);
        }
        public void TryRemoveShouldSucceedAndReturnData(
            MongoTimeoutPersister sut,
            MongoDatabaseFactory factory,
            Timeout.Core.TimeoutData timeoutData,
            ContextBag context)
        {
            factory.ResetTimeoutCollection();

            sut.Add(timeoutData, context).Wait();

            var timeouts = factory.RetrieveAllTimeouts();

            var result = sut.TryRemove(timeouts.First().Id, context).Result;

            result.Should().BeTrue();
            factory.RetrieveAllTimeouts().Should().HaveCount(0);
        }