public void IPAddressDAO_Update_SuccessfulUpdate(string ip, long timestampLocked, int registrationFailures, long lastRegFailTimestamp) { // Arrange UnitTestIPAddressDAO ipDAO = new UnitTestIPAddressDAO(); // Create an IP. IPAddressRecord ipRecord = new IPAddressRecord(ip, timestampLocked, registrationFailures, lastRegFailTimestamp); ipDAO.Create(ipRecord); // Prepare a new data to update. IPAddressRecord updatedRecord = new IPAddressRecord(ip, 1, 1, 1); // Act // Update the data of the IP. ipDAO.Update(updatedRecord); // Read the IP. IPAddressObject ipObject = (IPAddressObject)ipDAO.ReadById(ip); // Check if the IP was updated correctly and set the result to true. bool result = DataEquals(ipRecord, ipObject); // Assert // The result should be true. Assert.IsTrue(result); }
public void IPAddressDAO_ReadById_UnsuccessfulRead(string ip, long timestampLocked, int registrationFailures, long lastRegFailTimestamp) { // Arrange UnitTestIPAddressDAO ipDAO = new UnitTestIPAddressDAO(); // Create an IP. IPAddressRecord ipRecord = new IPAddressRecord(ip, timestampLocked, registrationFailures, lastRegFailTimestamp); ipDAO.Create(ipRecord); bool result = false; // Act try { // Read a non-existing IP. IPAddressObject ipObject = (IPAddressObject)ipDAO.ReadById(NonExistingIP); } catch (ArgumentException) { // Catch the exception and set the result to true. result = true; } // Assert // The result should be true. Assert.IsTrue(result); }
public void IPAddressDAO_Create_SuccessfulCreation(string ip, long timestampLocked, int registrationFailures, long lastRegFailTimestamp) { // Arrange UnitTestIPAddressDAO ipDAO = new UnitTestIPAddressDAO(); IPAddressRecord ipRecord = new IPAddressRecord(ip, timestampLocked, registrationFailures, lastRegFailTimestamp); // Act // Create IP Address. ipDAO.Create(ipRecord); IPAddressObject ipObject = (IPAddressObject)ipDAO.ReadById(ip); // Check if the data created is correct. bool correctDataResult = DataEquals(ipRecord, ipObject); // Assert // The data should be correct. Assert.IsTrue(correctDataResult); }
public void IPAddressDAO_ReadById_SuccessfulRead(string ip, long timestampLocked, int registrationFailures, long lastRegFailTimestamp) { // Arrange UnitTestIPAddressDAO ipDAO = new UnitTestIPAddressDAO(); // Create an IP. IPAddressRecord ipRecord = new IPAddressRecord(ip, timestampLocked, registrationFailures, lastRegFailTimestamp); ipDAO.Create(ipRecord); // Act // Read the IP. IPAddressObject ipObject = (IPAddressObject)ipDAO.ReadById(ip); // Check if the read IP is correct and set the result accordingly. bool result = DataEquals(ipRecord, ipObject); // Assert // The result should be true. Assert.IsTrue(result); }
/// <summary> /// Gets the <paramref name="ipAddress"/> info and return as an object. /// </summary> /// <param name="ipAddress">The ip address of the record in the data store (string)</param> /// <returns>Task (IPAddressObject) the object representing the ip info</returns> public static IPAddressObject GetIPAddressInfo(string ipAddress) { // Cast the return result of reading by the ip address into the IP object. return(_ipDAO.ReadById(ipAddress) as IPAddressObject); }