public void AddressDAOConstructorTest() { /*Context*/ AccountDAO acc_context = new AccountDAO(); AddressDAO address_context = new AddressDAO(); /*Insert*/ AccountDTO acc = new AccountDTO(); acc.userName = "******"; acc.password = "******"; acc.accountType = "administrator"; acc.status = "active"; Assert.AreEqual(true, acc_context.presist(acc)); AddressDTO address = new AddressDTO(); address.userName = "******"; address.addressType = "postal"; address.country = "South Africa"; address.province = "WP"; address.street = "Frans"; address.suburb = "Parow"; address.town = "Cape Town"; address.unitNumber = 22; Assert.AreEqual(true, address_context.presist(address)); /*Update*/ address.town = "Pretoria"; address_context.merge(address); string expectedUpdate = "Pretoria"; AddressDTO upd = address_context.find("john", "postal"); Assert.AreEqual(expectedUpdate, upd.town); /*Delete*/ address_context.removeByUserId("john", "postal"); bool expectedDelAddress = false; bool actualDeleteAddress = address_context.isFound("john", "postal"); Assert.AreEqual(expectedDelAddress, actualDeleteAddress); acc_context.removeByUserId("john"); }
public bool isUniqueAddress(String username, String addressType) { bool isUnique = false; AddressDAO addressDao = new AddressDAO(); try { return (!addressDao.isFound(username, addressType)); } catch (InvalidOperationException ioe) { isUnique = true; } return isUnique; }