Пример #1
0
 static Task Add(IPersistTimeouts inMemoryTimeoutPersister, ContextBag context)
 {
     return(inMemoryTimeoutPersister.Add(new TimeoutData
     {
         Time = DateTime.Now,
         Id = Thread.CurrentThread.Name
     }, context));
 }
Пример #2
0
        public void Should_retrieve_all_timeout_messages_that_expired()
        {
            expected = 50;

            Enumerable.Range(1, expected).ToList().ForEach(i => persister.Add(CreateData(DateTime.UtcNow.AddSeconds(-5))));

            StartAndStopReceiver();

            WaitForMessagesThenAssert(5);
        }
Пример #3
0
        public void Should_retrieve_all_timeout_messages_that_expired()
        {
            expected = 50;

            for (var i = 0; i < expected; i++)
            {
                persister.Add(CreateData(DateTime.UtcNow.AddSeconds(-5)));
            }

            StartAndStopReceiver();

            WaitForMessagesThenAssert(5);
        }
Пример #4
0
        public void Should_remove_timeouts_by_id()
        {
            var t1 = new TimeoutData {
                Id = "1", Time = DateTime.UtcNow.AddHours(-1)
            };

            persister.Add(t1);

            var t2 = new TimeoutData {
                Id = "2", Time = DateTime.UtcNow.AddHours(-1)
            };

            persister.Add(t2);

            var timeouts = GetNextChunk();

            foreach (var timeout in timeouts)
            {
                TimeoutData timeoutData;
                persister.TryRemove(timeout.Item1, out timeoutData);
            }

            Assert.AreEqual(0, GetNextChunk().Count);
        }
        public void Should_only_return_timeouts_for_time_slice()
        {
            const int numberOfTimeoutsToAdd = 10;

            for (var i = 0; i < numberOfTimeoutsToAdd; i++)
            {
                persister.Add(new TimeoutData
                {
                    OwningTimeoutManager = String.Empty,
                    Time = DateTime.UtcNow.AddHours(-1)
                });
            }

            for (var i = 0; i < numberOfTimeoutsToAdd; i++)
            {
                persister.Add(new TimeoutData
                {
                    OwningTimeoutManager = String.Empty,
                    Time = DateTime.UtcNow.AddHours(1)
                });
            }

            Assert.AreEqual(numberOfTimeoutsToAdd, GetNextChunk().Count);
        }
 public void Add(TimeoutData timeout)
 {
     originalTimeoutPersister.Add(timeout);
 }