コード例 #1
0
        public void TestPublishWithDelay()
        {
            MockJobInc.Publish(true, TimeSpan.FromSeconds(2));
            MockJobInc.Publish(true, TimeSpan.FromSeconds(2));

            _timeProvider.CurrentTimeUtc = DateTime.UtcNow;
            //FireActiveTimers();

            StopWorkers();
            Assert.AreEqual(0, _counter.Value);
            StartWorkers();

            _timeProvider.AdvanceTime(1000);
            //FireActiveTimers();

            StopWorkers();
            Assert.AreEqual(0, _counter.Value);
            StartWorkers();

            _timeProvider.AdvanceTime(1000);
            //FireActiveTimers();

            StopWorkers();
            Assert.AreEqual(2, _counter.Value);
        }
コード例 #2
0
        public void TestPublishInc()
        {
            MockJobInc.Publish(true);

            StopWorkers();

            Assert.AreEqual(1, _counter.Value);
        }
コード例 #3
0
        public void TestPublishDec()
        {
            MockJobInc.Publish(false);

            StopWorkers();

            Assert.AreEqual(-1, _counter.Value);
        }
コード例 #4
0
        public void TestCanceledAsyncJobs()
        {
            MockJobInc.Publish(true);
            MockAsyncJobCanceled.Publish();

            StopWorkers();

            Assert.AreEqual(1, _counter.Value);
            Assert.AreEqual(1, _messages.GetCount());
        }
コード例 #5
0
        public void TestFailedJobs()
        {
            MockJobInc.Publish(true);
            MockJobFailed.Publish(true);

            StopWorkers();

            Assert.AreEqual(1, _counter.Value);
            Assert.AreEqual(1, _messages.GetCount());
        }
コード例 #6
0
        public void TestLongRunningImmediateJob()
        {
            MockJobInc.Publish(true, 10_000);

            var totalLongRunning = 0;

            for (var i = 0; i < _settings.LongRunningWorkersCount; i++)
            {
                totalLongRunning +=
                    _messages.GetCount(string.Format(_settings.LongRunningQueueNameTemplate, i));
            }

            Assert.AreEqual(1, totalLongRunning);
        }