public void BorrowerTest() { // arrange BorrowerDAL dal = new BorrowerDAL(MagicSetup.Connection); // act create int rv1 = dal.BorrowerCreate("Test1", "Email", null, 1); Assert.IsTrue(rv1 > 0, $"BorrowerCreate failed rv = {rv1}"); Borrower a = dal.BorrowerFindByID(rv1); Assert.IsNotNull(a, $"BorrowerFindByID for ID {rv1} (just created) returned null"); Assert.IsTrue(a.BorrowerName == "Test1", $"BorrowerName was expected to be 'Test1' but found {a.BorrowerName}"); Assert.IsFalse(a.BorrowerDOB.HasValue, $"BorrowerDOB was expected to be null, but had a value"); Assert.IsTrue(a.RoleID == 1, $"Borrowerroleid was expected to be '1' but was actually '{a.RoleID}'"); int countofBorrowers = dal.BorrowerObtainCount(); Assert.IsTrue(countofBorrowers > 0, $"BorrowersObtainCount should be greater than 0 it is {countofBorrowers}"); List <Borrower> Borrowers = dal.BorrowersGetAll(); Assert.IsTrue(Borrowers.Count == countofBorrowers, $"BorrowersGetAll should have brought back {countofBorrowers} records, but it only found {Borrowers.Count}"); DateTime now = DateTime.Now; int number = dal.BorrowerUpdateJust(rv1, "Test1New", "EMail1", now, 2); Assert.IsTrue(number == 1, $"BorrowerUpdateJust was expected to return 1, but actually returned {number}"); a = dal.BorrowerFindByID(rv1); Assert.IsNotNull(a, $"BorrowerFindByID for ID {rv1} (just updated) returned null"); Assert.IsTrue(a.BorrowerName == "Test1New", $"BorrowerName after update was expected to be 'Test1New' but was actually '{a.BorrowerName}'"); Assert.IsTrue(a.BorrowerDOB.HasValue, "BorrowerDOB was expected to have a value, but was null"); Assert.IsTrue(a.RoleID == 2, $"BorrowerRoleID was expected to be 'newLocation1' but was actually '{a.RoleID}'"); number = dal.BorrowerUpdateSafe(rv1, "Test1New", "EMail1", now, 2, "1", "EMail2", null, 3); Assert.IsTrue(number == 1, $"BorrowerUpdateSafe was expected to return 1 but actually returned {number}"); a = dal.BorrowerFindByID(rv1); Assert.IsNotNull(a, $"BorrowerFindByID for ID {rv1} (just safe updated) returned null"); Assert.IsTrue(a.BorrowerName == "1", $"Borrowername after safeupdate was expected to be '1', but was '{a.BorrowerName}"); Assert.IsFalse(a.BorrowerDOB.HasValue, $"BorrowerDOB after safeupdate was expected to be null, but was not"); Assert.IsTrue(a.RoleID == 3, $"BorrowerRoleID after saftupdate was expected to be '3' but was actually '{a.RoleID}'"); number = dal.BorrowerUpdateSafe(rv1, "1", "EMail2", now, 2, "3", "EMail3", null, 4); Assert.IsTrue(number == 0, $"Borrowerupdatesafe was expected to return 0, but it actually returned {number}"); dal.BorrowerDelete(rv1); }
public int BorrowerUpdateSafe( int BorrowerID, string oldName, string oldEMail, DateTime?oldDOB, int oldRoleID, string newName, string newEMail, DateTime?newDOB, int newRoleID) { BorrowerDAL dal = new BorrowerDAL(_connection); return(dal.BorrowerUpdateSafe(BorrowerID, oldName, oldEMail, oldDOB, oldRoleID, newName, newEMail, newDOB, newRoleID)); }