Exemple #1
0
        public void Db_ErrorsReportingService_LogExceptionAsync_WithInner()
        {
            using (ThreadScopedLifestyle.BeginScope(container))
            {
                ErrorsReportingService service = container.GetInstance <ErrorsReportingService>();

                try
                {
                    ExceptionGenerator.ThrowsTwo();
                }
                catch (Exception exception)
                {
                    int?id = null;
                    Assert.That(async() =>
                    {
                        id = await service.LogExceptionAsync(this.dataSet.ApplicationsIds.ElementAt(0), exception, "ErrorType.Specific");
                    }, Throws.Nothing);

                    Assert.IsNotNull(id);

                    ErrorReportException ex      = this.exceptionsSqlHelper.GetBy(id.Value);
                    ErrorReportException innerEx = this.exceptionsSqlHelper.GetBy(ex.IdInnerException.Value);

                    Assert.AreEqual("Two", ex.Message);
                    Assert.AreEqual("One", innerEx.Message);
                }
            }
        }
Exemple #2
0
        public async Task Db_ErrorsReportingService_GetApplicationAsync()
        {
            using (ThreadScopedLifestyle.BeginScope(container))
            {
                ErrorsReportingService service = container.GetInstance <ErrorsReportingService>();

                ErrorReportApplication application = await service.GetApplicationAsync("TestApplicationAlreadyExisting", "a.a.a.a");

                Assert.IsNotNull(application);
                Assert.Greater(application.Id, 0);
                Assert.AreEqual(new DateTime(2000, 1, 1), application.FirstRunDate);
            }
        }
Exemple #3
0
        public void Db_ErrorsReportingService_CreateApplicationAsync_AlreadyExists()
        {
            using (ThreadScopedLifestyle.BeginScope(container))
            {
                ErrorsReportingService service = container.GetInstance <ErrorsReportingService>();

                DalException ex = Assert.ThrowsAsync <DalException>(async() =>
                {
                    await service.CreateApplicationAsync("TestApplicationAlreadyExisting", "a.a.a.a");
                });
                Assert.That(ex.errorType, Is.EqualTo(DalErrorType.SqlUniqueConstraintViolation));
            }
        }
Exemple #4
0
        public async Task Db_ErrorsReportingService_CreateApplicationAsync()
        {
            using (ThreadScopedLifestyle.BeginScope(container))
            {
                ErrorsReportingService service = container.GetInstance <ErrorsReportingService>();

                ErrorReportApplication result = await service.CreateApplicationAsync("TestApplicationAsync", "a.a.a.a");

                Assert.IsNotNull(result);
                Assert.Greater(result.Id, 0);

                this.dataSet.ApplicationsIds.Add(result.Id);
            }
        }
Exemple #5
0
        public void Db_ErrorsReportingService_GetApplicationAsync_NotExisting()
        {
            using (ThreadScopedLifestyle.BeginScope(container))
            {
                ErrorsReportingService service = container.GetInstance <ErrorsReportingService>();

                ErrorReportApplication application = null;
                Assert.That(async() =>
                {
                    application = await service.GetApplicationAsync("TestApplicationAlreadyExisting", "z.z.z.z");
                }, Throws.Nothing);

                Assert.IsNull(application);
            }
        }