public void IPAddressDAO_DeleteByIds_SuccessfulDeletion(string ip, long timestampLocked, int registrationFailures, long lastRegFailTimestamp) { // Arrange UnitTestIPAddressDAO ipDAO = new UnitTestIPAddressDAO(); // Create an IP address. IPAddressRecord ipRecord = new IPAddressRecord(ip, timestampLocked, registrationFailures, lastRegFailTimestamp); ipDAO.Create(ipRecord); // Act // Delete the IP address. ipDAO.DeleteByIds(new List <string>() { ip }); // Check if the IP exists and set the result accordingly. bool result = ipDAO.CheckIPExistence(ip); // Assert // The result should be false. Assert.IsFalse(result); }
public void IPAddressDAO_DeleteByIds_UnsuccessfulDeletion(string ip, long timestampLocked, int registrationFailures, long lastRegFailTimestamp) { // Arrange UnitTestIPAddressDAO ipDAO = new UnitTestIPAddressDAO(); // Create an IP address. IPAddressRecord ipRecord = new IPAddressRecord(ip, timestampLocked, registrationFailures, lastRegFailTimestamp); ipDAO.Create(ipRecord); bool result = false; // Act try { // Delete an non-existing IP. ipDAO.DeleteByIds(new List <string>() { NonExistingIP }); } catch (ArgumentException) { // Catch the exception and set the result to true. result = true; } // Assert // The result should be true. Assert.IsTrue(result); }