public async Task CleanUp() { IDataGateway dataGateway = new SQLServerGateway(); IConnectionStringData connectionString = new ConnectionStringData(); ILoginAttemptsRepository loginAttemptsRepository = new LoginAttemptsRepository(dataGateway, connectionString); var loginAttempts = await loginAttemptsRepository.GetAllLoginAttempts(); foreach (var loginAttempt in loginAttempts) { await loginAttemptsRepository.DeleteLoginAttemptsById(loginAttempt.Id); } await DataAccessTestHelper.ReseedAsync("LoginAttempts", 0, connectionString, dataGateway); }
public async Task DeleteLoginAttemptsById_LoginAttemptsExists_LoginAttemptsIsNull(int id) { // Arrange ILoginAttemptsRepository loginAttemptsRepository = new LoginAttemptsRepository(new SQLServerGateway(), new ConnectionStringData()); // Act await loginAttemptsRepository.DeleteLoginAttemptsById(id); var retrievedLoginAttempt = await loginAttemptsRepository.GetLoginAttemptsById(id); // Assert Assert.IsNull(retrievedLoginAttempt); }
public async Task DeleteLoginAttemptsById_ExecutionTimeLessThan400Milliseconds (int id, long expectedMaxExecutionTime) { // Arrange ILoginAttemptsRepository loginAttemptsRepository = new LoginAttemptsRepository (new SQLServerGateway(), new ConnectionStringData()); // Act var timer = Stopwatch.StartNew(); await loginAttemptsRepository.DeleteLoginAttemptsById(id); timer.Stop(); var actualExecutionTime = timer.ElapsedMilliseconds; Debug.WriteLine("Actual Execution Time: " + actualExecutionTime); // Assert Assert.IsTrue(actualExecutionTime <= expectedMaxExecutionTime); }