コード例 #1
0
 public async Task When_empty_NextTimeToRunQuery_is_1_minute()
 {
     var now = DateTime.UtcNow;
     var persister = new InMemoryTimeoutPersister(() => DateTime.UtcNow);
     var result = await persister.GetNextChunk(now);
     Assert.That(result.NextTimeToQuery, Is.EqualTo(now.AddMinutes(1)).Within(100).Milliseconds);
 }
コード例 #2
0
 void GetNextChunk(InMemoryTimeoutPersister inMemoryTimeoutPersister)
 {
     for (var i = 0; i < 10; i++)
     {
         DateTime nextTimeToRunQuery;
         inMemoryTimeoutPersister.GetNextChunk(DateTime.MinValue, out nextTimeToRunQuery).ToList();
     }
 }
コード例 #3
0
        public async Task When_empty_NextTimeToRunQuery_is_1_minute()
        {
            var now       = DateTime.UtcNow;
            var persister = new InMemoryTimeoutPersister(() => DateTime.UtcNow);
            var result    = await persister.GetNextChunk(now);

            Assert.That(result.NextTimeToQuery, Is.EqualTo(now.AddMinutes(1)).Within(100).Milliseconds);
        }
コード例 #4
0
        public async Task When_multiple_NextTimeToRunQuery_is_min_date()
        {
            var now = DateTime.UtcNow;
            var persister = new InMemoryTimeoutPersister(() => DateTime.UtcNow);
            await persister.Add(new TimeoutData
                          {
                              Time = DateTime.Now.AddDays(2)
                          }, new ContextBag());
            var expectedDate = DateTime.Now.AddDays(1);
            await persister.Add(new TimeoutData
                          {
                              Time = expectedDate
                          }, new ContextBag());

            var result = await persister.GetNextChunk(now);

            Assert.AreEqual(expectedDate, result.NextTimeToQuery);
        }
コード例 #5
0
        public void When_multiple_NextTimeToRunQuery_is_min_date()
        {
            DateTime nextTimeToRunQuery;
            var      now       = DateTime.UtcNow;
            var      persister = new InMemoryTimeoutPersister();

            persister.Add(new TimeoutData
            {
                Time = DateTime.Now.AddDays(2)
            });
            var expectedDate = DateTime.Now.AddDays(1);

            persister.Add(new TimeoutData
            {
                Time = expectedDate
            });
            persister.GetNextChunk(now, out nextTimeToRunQuery);
            Assert.AreEqual(expectedDate, nextTimeToRunQuery);
        }
コード例 #6
0
        public async Task When_multiple_NextTimeToRunQuery_is_min_date()
        {
            var now       = DateTime.UtcNow;
            var persister = new InMemoryTimeoutPersister(() => DateTime.UtcNow);
            await persister.Add(new TimeoutData
            {
                Time = DateTime.Now.AddDays(2)
            }, new ContextBag());

            var expectedDate = DateTime.Now.AddDays(1);
            await persister.Add(new TimeoutData
            {
                Time = expectedDate
            }, new ContextBag());

            var result = await persister.GetNextChunk(now);

            Assert.AreEqual(expectedDate, result.NextTimeToQuery);
        }
コード例 #7
0
        public async Task When_multiple_future_are_returned()
        {
            var persister = new InMemoryTimeoutPersister(() => DateTime.UtcNow);
            await persister.Add(new TimeoutData
                          {
                              Time = DateTime.Now.AddDays(-2)
                          }, new ContextBag());
            await persister.Add(new TimeoutData
                          {
                              Time = DateTime.Now.AddDays(-4)
                          }, new ContextBag());
            await persister.Add(new TimeoutData
                          {
                              Time = DateTime.Now.AddDays(-1)
                          }, new ContextBag());

            var result = await persister.GetNextChunk(DateTime.Now.AddDays(-3));

            Assert.AreEqual(2, result.DueTimeouts.Count());
        }
コード例 #8
0
        public void When_all_in_past_NextTimeToRunQuery_is_1_minute()
        {
            DateTime nextTimeToRunQuery;
            var      now       = DateTime.UtcNow;
            var      persister = new InMemoryTimeoutPersister();

            persister.Add(new TimeoutData
            {
                Time = DateTime.Now.AddDays(-1)
            });
            persister.Add(new TimeoutData
            {
                Time = DateTime.Now.AddDays(-3)
            });
            persister.Add(new TimeoutData
            {
                Time = DateTime.Now.AddDays(-2)
            });
            persister.GetNextChunk(now, out nextTimeToRunQuery);
            Assert.That(nextTimeToRunQuery, Is.EqualTo(now.AddMinutes(1)).Within(100).Milliseconds);
        }
コード例 #9
0
        public void When_multiple_future_are_returned()
        {
            DateTime nextTime;
            var      persister = new InMemoryTimeoutPersister();

            persister.Add(new TimeoutData
            {
                Time = DateTime.Now.AddDays(-2)
            });
            persister.Add(new TimeoutData
            {
                Time = DateTime.Now.AddDays(-4)
            });
            persister.Add(new TimeoutData
            {
                Time = DateTime.Now.AddDays(-1)
            });
            var nextChunk = persister.GetNextChunk(DateTime.Now.AddDays(-3), out nextTime);

            Assert.AreEqual(2, nextChunk.Count());
        }
コード例 #10
0
        public async Task When_multiple_future_are_returned()
        {
            var persister = new InMemoryTimeoutPersister(() => DateTime.UtcNow);
            await persister.Add(new TimeoutData
            {
                Time = DateTime.Now.AddDays(-2)
            }, new ContextBag());

            await persister.Add(new TimeoutData
            {
                Time = DateTime.Now.AddDays(-4)
            }, new ContextBag());

            await persister.Add(new TimeoutData
            {
                Time = DateTime.Now.AddDays(-1)
            }, new ContextBag());

            var result = await persister.GetNextChunk(DateTime.Now.AddDays(-3));

            Assert.AreEqual(2, result.DueTimeouts.Count());
        }
コード例 #11
0
        public async Task When_all_in_past_NextTimeToRunQuery_is_1_minute()
        {
            var now       = DateTime.UtcNow;
            var persister = new InMemoryTimeoutPersister(() => DateTime.UtcNow);
            await persister.Add(new TimeoutData
            {
                Time = DateTime.Now.AddDays(-1)
            }, new ContextBag());

            await persister.Add(new TimeoutData
            {
                Time = DateTime.Now.AddDays(-3)
            }, new ContextBag());

            await persister.Add(new TimeoutData
            {
                Time = DateTime.Now.AddDays(-2)
            }, new ContextBag());

            var result = await persister.GetNextChunk(now);

            Assert.That(result.NextTimeToQuery, Is.EqualTo(now.AddMinutes(1)).Within(100).Milliseconds);
        }
コード例 #12
0
 Task <TimeoutsChunk> GetNextChunk()
 {
     return(persister.GetNextChunk(DateTime.UtcNow.AddYears(-3)));
 }
コード例 #13
0
        public async Task When_all_in_past_NextTimeToRunQuery_is_1_minute()
        {
            var now = DateTime.UtcNow;
            var persister = new InMemoryTimeoutPersister(() => DateTime.UtcNow);
            await persister.Add(new TimeoutData
                          {
                              Time = DateTime.Now.AddDays(-1)
                          }, new ContextBag());
            await persister.Add(new TimeoutData
                          {
                              Time = DateTime.Now.AddDays(-3)
                          }, new ContextBag());
            await persister.Add(new TimeoutData
                          {
                              Time = DateTime.Now.AddDays(-2)
                          }, new ContextBag());

            var result = await persister.GetNextChunk(now);

            Assert.That(result.NextTimeToQuery, Is.EqualTo(now.AddMinutes(1)).Within(100).Milliseconds);
        }