public async Task IncrementLoginCounterById_LoginCounterIsAccurate(int id) { // Arrange ILoginAttemptsRepository loginAttemptsRepository = new LoginAttemptsRepository(new SQLServerGateway(), new ConnectionStringData()); // Act var oldLoginAttempt = await loginAttemptsRepository.GetLoginAttemptsById(id); await loginAttemptsRepository.IncrementLoginCounterById(id); var newLoginAttempt = await loginAttemptsRepository.GetLoginAttemptsById(id); // Assert Assert.IsTrue(newLoginAttempt.LoginCounter == (oldLoginAttempt.LoginCounter + 1)); }
public async Task IncrementLoginCounterById_ExecutionTimeLessThan400Milliseconds (int id, long expectedMaxExecutionTime) { // Arrange ILoginAttemptsRepository loginAttemptsRepository = new LoginAttemptsRepository (new SQLServerGateway(), new ConnectionStringData()); // Act var timer = Stopwatch.StartNew(); await loginAttemptsRepository.IncrementLoginCounterById(id); timer.Stop(); var actualExecutionTime = timer.ElapsedMilliseconds; Debug.WriteLine("Actual Execution Time: " + actualExecutionTime); // Assert Assert.IsTrue(actualExecutionTime <= expectedMaxExecutionTime); }