public async void Async_Unopened_UnitOfWork_Throws_Exception() { IConnectionRepo repo = new FakeRepository(_provider.Object); repo.AsyncUnitOfWork = _asyncUnitOfWork.Object; _asyncUnitOfWork.Setup(uow => uow.NumberOfRepos).Returns(1); await Assert.ThrowsAsync <Exception>(async() => await repo.ExecuteAsync("sql")); }
public async void DeadLock_Async_Exception_Should_Be_Retried_Once() { int counter = 0; SqlException ex = new SqlExceptionBuilder().WithErrorNumber(BaseRepository.DEADLOCK_ERROR_NBR) .WithErrorMessage("Fake Deadlock") .Build(); _asyncUnitOfWork.Setup(uow => uow.ExecuteAsync("deadlock", null, null)).Returns(async() => { if (counter == 0) { counter++; throw ex; } return(counter); }); int result = await _repo.ExecuteAsync("deadlock"); result.Should().Be(1); }