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 CreateLoginAttempts_IpAddressDoesntExist_DataIsAccurate (int expectedId, string expectedIpAddress, int expectedLoginCounter, string expectedSuspensionEndTime) { // Arrange ILoginAttemptsRepository loginAttemptsRepository = new LoginAttemptsRepository (new SQLServerGateway(), new ConnectionStringData()); LoginAttemptsModel loginAttemptsModel = new LoginAttemptsModel(); loginAttemptsModel.Id = expectedId; loginAttemptsModel.IpAddress = expectedIpAddress; loginAttemptsModel.LoginCounter = expectedLoginCounter; loginAttemptsModel.SuspensionEndTime = DateTimeOffset.Parse(expectedSuspensionEndTime); // Act await loginAttemptsRepository.CreateLoginAttempts(loginAttemptsModel); var actualLoginAttempt = await loginAttemptsRepository.GetLoginAttemptsById(expectedId); // Assert Assert.IsTrue ( actualLoginAttempt.Id == expectedId && actualLoginAttempt.IpAddress == expectedIpAddress && actualLoginAttempt.LoginCounter == expectedLoginCounter && actualLoginAttempt.SuspensionEndTime == DateTimeOffset.Parse(expectedSuspensionEndTime) ); }
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 GetLoginAttemptsById_LoginAttemptExists_IpAddressCorrect(int expectedId, string expectedIpAddress) { // Arrange ILoginAttemptsRepository loginAttemptsRepository = new LoginAttemptsRepository(new SQLServerGateway(), new ConnectionStringData()); // Act var loginAttemptModel = await loginAttemptsRepository.GetLoginAttemptsById(expectedId); var actualIpAddress = loginAttemptModel.IpAddress; // Assert Assert.IsTrue(actualIpAddress == expectedIpAddress); }
public async Task GetLoginAttemptsById_LoginAttemptExists_ReturnsLoginAttempts(int expectedId) { // Arrange ILoginAttemptsRepository loginAttemptsRepository = new LoginAttemptsRepository(new SQLServerGateway(), new ConnectionStringData()); // Act var loginAttemptModel = await loginAttemptsRepository.GetLoginAttemptsById(expectedId); var actualId = loginAttemptModel.Id; // Assert Assert.IsTrue(actualId == expectedId); }
public async Task UpdateSuspensionEndTimeById_SuspensionEndtimeIsAccurate(int id, string expectedSuspensionEndTime) { // Arrange ILoginAttemptsRepository loginAttemptsRepository = new LoginAttemptsRepository(new SQLServerGateway(), new ConnectionStringData()); // Act await loginAttemptsRepository.UpdateSuspensionEndTimeById(id, DateTimeOffset.Parse(expectedSuspensionEndTime)); var newLoginAttempt = await loginAttemptsRepository.GetLoginAttemptsById(id); var actualSuspensionEndTime = newLoginAttempt.SuspensionEndTime; // Assert Assert.IsTrue(actualSuspensionEndTime == DateTimeOffset.Parse(expectedSuspensionEndTime)); }