Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }