Beispiel #1
0
        public void Given_the_worker_is_stopped_Should_notify_pending_queue_notifications()
        {
            ErrorQueue.Push(new Error("error"));

            _testErrorSenderWorker.Start();

            Assert.IsFalse(_testErrorSenderWorker.DeliveredTask.Wait(TimeSpan.FromSeconds(1)));

            Assert.IsTrue(_testErrorSenderWorker.Stop(TimeSpan.FromSeconds(10)));

            Assert.IsTrue(_testErrorSenderWorker.DeliveredTask.Wait(TimeSpan.Zero));

            Assert.AreEqual(1, _testErrorSenderWorker.DeliveredTask.Result.Errors.Length);
        }
Beispiel #2
0
        public void Given_the_queue_has_the_same_or_more_items_than_the_max_batch_Should_not_wait()
        {
            ErrorQueue.Push(new Error("error"));

            ErrorQueue.Push(new Error("error2"));

            _testErrorSenderWorker.Start();

            Assert.IsTrue(_testErrorSenderWorker.DeliveredTask.Wait(TimeSpan.FromSeconds(1)));

            Assert.AreEqual(2, _testErrorSenderWorker.DeliveredTask.Result.Errors.Length);

            Assert.IsTrue(_testErrorSenderWorker.Stop(TimeSpan.FromSeconds(10)));
        }
Beispiel #3
0
        public void Given_the_message_is_modified_through_the_on_delivery_error_Should_reflect_it_in_the_notified_error()
        {
            var            guid   = Guid.NewGuid().ToString();
            Action <Error> action = error => error.Location = guid;

            Glitch.Notifications.OnErrorDelivering += action;

            ErrorQueue.Push(new Error("error"));
            _testErrorSenderWorker.Start();
            Assert.IsTrue(_testErrorSenderWorker.Stop(TimeSpan.FromSeconds(10)));
            Glitch.Notifications.OnErrorDelivering -= action;
            Assert.IsTrue(_testErrorSenderWorker.DeliveredTask.Wait(TimeSpan.Zero));

            Assert.AreEqual(guid, _testErrorSenderWorker.DeliveredTask.Result.Errors.First().Location);
        }