public async Task AddAsync_WhenExceptionIsNull_ThrowsArgumentNullException() { Exception exception = null; IExceptionRepository sut = CreateSut(); await sut.AddAsync(exception); }
public async Task AddAsync_WhenCalled_ExpectNoError() { Exception exception = new Exception(); IExceptionRepository sut = CreateSut(); await sut.AddAsync(exception); }
public async Task GetSystemErrorsAsyncTests_WhenCalled_ReturnsSystemErrors() { Exception firstException = new Exception(Guid.NewGuid().ToString("D")); Exception secondException = new Exception(Guid.NewGuid().ToString("D")); Exception thirdException = new Exception(Guid.NewGuid().ToString("D")); IExceptionRepository sut = CreateSut(); await sut.AddAsync(firstException); await sut.AddAsync(secondException); await sut.AddAsync(thirdException); IEnumerable <ISystemError> result = await sut.GetSystemErrorsAsync(); Assert.IsNotNull(result); Assert.IsTrue(result.Any()); Assert.IsNotNull(result.FirstOrDefault(systemError => string.Compare(systemError.Information, firstException.Message, StringComparison.InvariantCulture) == 0)); Assert.IsNotNull(result.FirstOrDefault(systemError => string.Compare(systemError.Information, secondException.Message, StringComparison.InvariantCulture) == 0)); Assert.IsNotNull(result.FirstOrDefault(systemError => string.Compare(systemError.Information, thirdException.Message, StringComparison.InvariantCulture) == 0)); }
public async Task GetSystemErrorsAsyncTests_WhenCalled_RemoveSystemErrors() { Exception firstException = new Exception(); Exception secondException = new Exception(); Exception thirdException = new Exception(); IExceptionRepository sut = CreateSut(); await sut.AddAsync(firstException); await sut.AddAsync(secondException); await sut.AddAsync(thirdException); IEnumerable <ISystemError> firstGetSystemErrors = await sut.GetSystemErrorsAsync(); Assert.IsNotNull(firstGetSystemErrors); Assert.IsTrue(firstGetSystemErrors.Any()); IEnumerable <ISystemError> secondGetSystemErrors = await sut.GetSystemErrorsAsync(); Assert.IsNotNull(secondGetSystemErrors); Assert.IsFalse(secondGetSystemErrors.Any()); }
private void AddToRepository(Exception exception) { if (exception == null) { throw new ArgumentNullException(nameof(exception)); } try { _exceptionRepository.AddAsync(exception).GetAwaiter().GetResult(); } catch (AggregateException aggregateException) { aggregateException.Handle(ex => true); } catch (Exception ex) { LogException(new StackTrace().GetFrame(0), ex); } }