public void verify_max_number_of_falure()
        {
            var info = new QueueInfo("test", "tika", "");

            info.MaxNumberOfFailure = 2;
            QueueHandler sut = CreateAGenericJob(info);

            var nextJob = sut.GetNextJob("", "handle", null, null);

            Assert.That(nextJob, Is.Not.Null);
            var jobId = nextJob.Id;

            sut.SetJobExecuted(nextJob.Id, "Error 42", null);
            nextJob = sut.GetNextJob("", "handle", null, null);
            Assert.That(nextJob, Is.Not.Null);
            sut.SetJobExecuted(nextJob.Id, "Error 42", null);
            nextJob = sut.GetNextJob("", "handle", null, null);
            Assert.That(nextJob, Is.Null, "After two failure the job should not be returned anymore");

            var collection = _db.GetCollection <QueuedJob>("queue.test");
            var job        = collection.Find(Builders <QueuedJob> .Filter.Eq(j => j.Id, jobId)).SingleOrDefault();

            Assert.That(job.ExecutionError, Is.EqualTo("Error 42"));
            Assert.That(job.ErrorCount, Is.EqualTo(2));
            Assert.That(job.Status, Is.EqualTo(QueuedJobExecutionStatus.Failed));
        }
        public void verify_set_error_status()
        {
            var info = new QueueInfo("test", "tika", "");

            info.MaxNumberOfFailure = 2;
            QueueHandler sut     = CreateAGenericJob(info);
            var          nextJob = sut.GetNextJob("", "handle", null, null);

            sut.SetJobExecuted(nextJob.Id, "Error 42", null);
            var collection = _db.GetCollection <QueuedJob>("queue.test");
            var job        = collection.Find(Builders <QueuedJob> .Filter.Eq(j => j.Id, nextJob.Id)).SingleOrDefault();

            Assert.That(job.ExecutionError, Is.EqualTo("Error 42"));
            Assert.That(job.ErrorCount, Is.EqualTo(1));
            Assert.That(job.Status, Is.EqualTo(QueuedJobExecutionStatus.ReQueued));
        }