public void DeleteMethodOK() { ClsStaffCollection allStaff = new ClsStaffCollection(); ClsStaff testItem = new ClsStaff(); int primaryKey = 0; testItem.StaffID = 1; testItem.StaffName = "Bill Gates"; testItem.OfficeCode = 1; testItem.PositionID = 1; testItem.ContactNumber = "12345678910"; testItem.Address = "10 Park Road, Leicester, LE1 2PR"; testItem.HireDate = DateTime.Now.Date; testItem.IsEmployed = true; allStaff.ThisStaff = testItem; primaryKey = allStaff.Add(); testItem.StaffID = primaryKey; allStaff.ThisStaff.Find(primaryKey); allStaff.Delete(); bool found = allStaff.ThisStaff.Find(primaryKey); Assert.IsFalse(found); }
public void UpdateMethodOK() { ClsStaffCollection allStaff = new ClsStaffCollection(); ClsStaff testItem = new ClsStaff(); int primaryKey = 0; testItem.StaffID = 1; testItem.StaffName = "Bill Gates"; testItem.OfficeCode = 1; testItem.PositionID = 1; testItem.ContactNumber = "12345678910"; testItem.Address = "10 Park Road, Leicester, LE1 2PR"; testItem.HireDate = DateTime.Now.Date; testItem.IsEmployed = true; allStaff.ThisStaff = testItem; primaryKey = allStaff.Add(); testItem.StaffName = "Steve Ballmer"; testItem.OfficeCode = 2; testItem.PositionID = 3; testItem.ContactNumber = "9876543210"; testItem.Address = "11 Ground Road, Liverpool, LP1 2RP"; testItem.HireDate = DateTime.Now.Date; testItem.IsEmployed = true; allStaff.ThisStaff = testItem; allStaff.Update(); allStaff.ThisStaff.Find(primaryKey); Assert.AreEqual(allStaff.ThisStaff, testItem); }
protected void BtnFind_Click(object sender, EventArgs e) { ClsStaff member = new ClsStaff(); int staffID; Boolean Found = false; if (System.Text.RegularExpressions.Regex.IsMatch(TbStaffID.Text, "^[a-zA-Z]*$")) { Response.Redirect("StaffPage.aspx"); } staffID = Convert.ToInt32(TbStaffID.Text); Found = member.Find(staffID); if (Found == true) { TbStaffName.Text = member.StaffName; TbOfficeCode.Text = member.OfficeCode.ToString(); TbPositionID.Text = member.PositionID.ToString(); TbContactNumber.Text = member.ContactNumber; TbAddress.Text = member.Address; TbHireDate.Text = member.HireDate.ToShortDateString(); CbIsEmployed.Checked = member.IsEmployed; } }
public void OfficeCodePropertyOK() { ClsStaff member = new ClsStaff(); int testData = 03; member.OfficeCode = testData; Assert.AreEqual(member.OfficeCode, testData); }
public void ContactNumberPropertyOK() { ClsStaff member = new ClsStaff(); string testData = "07456330713"; member.ContactNumber = testData; Assert.AreEqual(member.ContactNumber, testData); }
public void StaffNamePropertyOK() { ClsStaff member = new ClsStaff(); string testData = "Bill Gates"; member.StaffName = testData; Assert.AreEqual(member.StaffName, testData); }
public void AddressPropertyOK() { ClsStaff member = new ClsStaff(); string testData = "1 Park Road, Leicester, LE2 1PK"; member.Address = testData; Assert.AreEqual(member.Address, testData); }
public void HireDatePropertyOK() { ClsStaff member = new ClsStaff(); DateTime testData = DateTime.Now.Date; member.HireDate = testData; Assert.AreEqual(member.HireDate, testData); }
public void IsEmployedPropertyOK() { ClsStaff member = new ClsStaff(); bool testData = true; member.IsEmployed = testData; Assert.AreEqual(member.IsEmployed, testData); }
public void PositionIDPropertyOK() { ClsStaff member = new ClsStaff(); int testData = 1; member.PositionID = testData; Assert.AreEqual(member.PositionID, testData); }
public void AddressMinPlus1() { ClsStaff member = new ClsStaff(); string error = ""; string address = "AA"; error = member.Valid(staffName, contactNumber, address, hireDate); Assert.AreEqual(error, ""); }
public void ContactNumberMaxPlus1() { ClsStaff member = new ClsStaff(); string error = ""; string contactNumber = "0122345547859736"; error = member.Valid(staffName, contactNumber, address, hireDate); Assert.AreNotEqual(error, ""); }
public void ContactNumberMax() { ClsStaff member = new ClsStaff(); string error = ""; string contactNumber = "012234567898765"; error = member.Valid(staffName, contactNumber, address, hireDate); Assert.AreEqual(error, ""); }
public void DateInvalid() { ClsStaff member = new ClsStaff(); string error = ""; string hireDate = "This is a date!"; error = member.Valid(staffName, contactNumber, address, hireDate); Assert.AreNotEqual(error, ""); }
public void ValidMethodOK() { ClsStaff member = new ClsStaff(); String Error = ""; Error = member.Valid(staffName, contactNumber, address, hireDate); Assert.AreEqual(Error, ""); }
public void AddressMaxLess1() { ClsStaff member = new ClsStaff(); string error = ""; string address = ""; address = address.PadRight(49, 'A'); error = member.Valid(staffName, contactNumber, address, hireDate); Assert.AreEqual(error, ""); }
public void AddressMaxExtreme() { ClsStaff member = new ClsStaff(); string error = ""; string address = ""; contactNumber = contactNumber.PadRight(500, 'A'); error = member.Valid(staffName, contactNumber, address, hireDate); Assert.AreNotEqual(error, ""); }
protected void Page_Load(object sender, EventArgs e) { // Create a new instance of ClsStaff ClsStaff member = new ClsStaff(); // Get the data from the session object member = (ClsStaff)Session["member"]; // Display the staff name for this entry Response.Write(member.StaffName); }
public void FindMethodOK() { ClsStaff member = new ClsStaff(); bool Found = false; int StaffID = 1; Found = member.Find(StaffID); Assert.IsTrue(Found); }
public void StaffNameMin() { ClsStaff member = new ClsStaff(); String error = ""; string staffName = "A"; error = member.Valid(staffName, contactNumber, address, hireDate); Assert.AreEqual(error, ""); }
public void DateMin() { ClsStaff member = new ClsStaff(); string error = ""; DateTime testDate; testDate = DateTime.Now.Date; string hireDate = testDate.ToString(); error = member.Valid(staffName, contactNumber, address, hireDate); Assert.AreEqual(error, ""); }
public void StaffNameMaxPlus1() { ClsStaff member = new ClsStaff(); String error = ""; string staffName = ""; staffName = staffName.PadRight(31, 'A'); error = member.Valid(staffName, contactNumber, address, hireDate); Assert.AreNotEqual(error, ""); }
protected void BtnSubmit_Click(object sender, EventArgs e) { ClsStaff member = new ClsStaff(); string staffName = TbStaffName.Text; string officeCode = TbOfficeCode.Text; string positionID = TbPositionID.Text; string contactNumber = TbContactNumber.Text; string address = TbAddress.Text; string hireDate = TbHireDate.Text; string error = ""; error = member.Valid(staffName, contactNumber, address, hireDate); if (error == "") { member.StaffID = staffID; member.StaffName = staffName; member.OfficeCode = Convert.ToInt32(officeCode); member.PositionID = Convert.ToInt32(positionID); member.ContactNumber = contactNumber; member.Address = address; member.HireDate = Convert.ToDateTime(hireDate); member.IsEmployed = CbIsEmployed.Checked; ClsStaffCollection members = new ClsStaffCollection(); if (staffID == -1) { members.ThisStaff = member; members.Add(); } else { members.ThisStaff.Find(staffID); members.ThisStaff = member; members.Update(); } Response.Redirect("StaffList.aspx"); } else { LblError.Text = error; } }
public void ThisStaffPropertyOK() { ClsStaffCollection allStaff = new ClsStaffCollection(); ClsStaff testStaff = new ClsStaff(); testStaff.StaffID = 1; testStaff.StaffName = "Bill Gates"; testStaff.OfficeCode = 1; testStaff.PositionID = 1; testStaff.ContactNumber = "12345678910"; testStaff.Address = "10 Park Road, Leicester, LE1 2PR"; testStaff.HireDate = DateTime.Now.Date; testStaff.IsEmployed = true; allStaff.ThisStaff = testStaff; Assert.AreEqual(allStaff.ThisStaff, testStaff); }
public void TestPositionIDFound() { ClsStaff member = new ClsStaff(); bool Found = false; bool OK = true; int ID = 1; Found = member.Find(ID); if (member.PositionID != 3) { OK = false; } Assert.IsTrue(OK); }
public void TestContactNumberFound() { ClsStaff member = new ClsStaff(); bool Found = false; bool OK = true; int ID = 1; Found = member.Find(ID); if (member.ContactNumber != "09876543210") { OK = false; } Assert.IsTrue(OK); }
public void TestAddressFound() { ClsStaff member = new ClsStaff(); bool found = false; bool OK = true; int ID = 1; found = member.Find(ID); if (member.Address != "11 Ground Road, Liverpool, LP1 2RP") { OK = false; } Assert.IsTrue(OK); }
public void TestHireDateFound() { ClsStaff member = new ClsStaff(); bool Found = false; bool OK = true; int StaffID = 1; Found = member.Find(StaffID); if (member.HireDate != DateTime.Now.Date) { OK = false; } Assert.IsTrue(OK); }
public void TestIsEmployedFound() { ClsStaff member = new ClsStaff(); bool Found = false; bool OK = true; int ID = 1; Found = member.Find(ID); if (member.IsEmployed != true) { OK = false; } Assert.IsTrue(OK); }
public void TestOfficeCodeFound() { ClsStaff member = new ClsStaff(); bool Found = false; bool OK = true; int ID = 1; Found = member.Find(ID); if (member.OfficeCode != 2) { OK = false; } Assert.IsTrue(OK); }