Example #1
0
 private void ClearError(CertificateTask certificateTask)
 {
     if (Errors.ContainsKey(certificateTask.GetErrorId()))
     {
         Errors.Remove(certificateTask.GetErrorId());
     }
 }
        private void CheckErrors(CertificateTask task, MemoryAppender memoryAppender, TestCertificateSourceHandler handler, uint errorCount, bool idEquals = false)
        {
            var firstEvents = memoryAppender.GetEvents();

            var firstErrors = firstEvents.Where(item => item.Level >= Level.Warn);

            Assert.That(firstErrors.Count(), Is.EqualTo(errorCount), firstErrors.Implode(e => e.MessageObject));

            //кол-во ошибок должно быть равно 1
            Assert.That(handler.Errors.Count, Is.EqualTo(1));

            var info = handler.Errors[task.GetErrorId()];

            Assert.That(info.ErrorCount, Is.EqualTo(errorCount));
            Assert.That(info.Exception.Message, Is.StringStarting("Возникла ошибка при обработке задачи: "));
            if (idEquals)
            {
                Assert.That(info.Task.Id, Is.EqualTo(task.Id));
            }
            Assert.That(info.Task.CertificateSource.Id, Is.EqualTo(task.CertificateSource.Id));
            Assert.That(info.Task.CatalogProduct.Id, Is.EqualTo(task.CatalogProduct.Id));
            Assert.That(info.Task.SerialNumber, Is.EqualTo(task.SerialNumber));

            //Задача должна быть удалена из базы данных
            var deletedTask = CertificateTask.Queryable.FirstOrDefault(t => t.Id == task.Id);

            Assert.That(deletedTask, Is.Null);
        }
Example #3
0
        private CertificateTaskErrorInfo FindError(CertificateTask task, Exception exception)
        {
            CertificateTaskErrorInfo result;

            if (Errors.ContainsKey(task.GetErrorId()))
            {
                result = Errors[task.GetErrorId()];
                result.UpdateError(exception);
            }
            else
            {
                result = new CertificateTaskErrorInfo(task, exception);
                Errors[task.GetErrorId()] = result;
            }

            return(result);
        }