public void ListAndCountOK() { //create an instance of the class we want to create clsMemberCollection AllMembers = new clsMemberCollection(); //create some test data to assign to the property //in this case the data needs to be a list of objects List <clsMember> Test = new List <clsMember>(); //add an item to the list //create the item of test data clsMember Test1 = new clsMember(); //set the properties of the test object Test1.FullName = "Sofyan Koultouma"; Test1.Address = "1 Leicester Road"; Test1.PhoneNumber = "07856681247"; Test1.DOB = DateTime.Parse("1998/07/08"); Test1.MemberID = 10; Test1.MedicalConditions = false; //add the item to the test list Test.Add(Test1); //asign the data to the property AllMembers.MemberList = Test; //test to see that the wo values are the same Assert.AreEqual(AllMembers.Count, Test.Count); }
public void AddMethodOK() { //create an instance of the class we want to create clsMemberCollection AllMembers = new clsMemberCollection(); //create the item of test data clsMember Test1 = new clsMember(); //var to store the primary key Int32 PrimaryKey = 0; //set its properties Test1.FullName = "Sofyan Koultouma"; Test1.Address = "1 Leicester Road"; Test1.PhoneNumber = "07856681247"; Test1.DOB = DateTime.Parse("1988/07/08"); Test1.MemberID = 20; Test1.MedicalConditions = true; //set ThisAddress to the test data AllMembers.ThisMember = Test1; //add the record PrimaryKey = AllMembers.Add(); //set the primary key to the test data Test1.MemberID = PrimaryKey; //find the record AllMembers.ThisMember.Find(PrimaryKey); //test to see that the two values are the same Assert.AreEqual(AllMembers.ThisMember, Test1); }
public void ReportByDOBFound() { //create an instance of the filtered data clsMemberCollection FilteredMembers = new clsMemberCollection(); //var to store the outcome Boolean OK = true; //apply a DOB that doesn't exist (but is in the database) FilteredMembers.ReportByDOB("1990-03-05"); //check that the correct number of records are found if (FilteredMembers.Count == 2) { //check that the first record ID is 4 if (FilteredMembers.MemberList[0].MemberID != 4) { OK = false; } //check that the second record ID is 5 if (FilteredMembers.MemberList[1].MemberID != 5) { OK = false; } } else { OK = false; } //test to to see the correct amount of records were shown Assert.IsTrue(OK); }
public void DeleteMethodOK() { //create an instance of the class we want to create clsMemberCollection AllMembers = new clsMemberCollection(); //create an item of test data clsMember Test1 = new clsMember(); //var to store the primary key Int32 PrimaryKey = 0; //set its properties Test1.FullName = "Sofyan Koultouma"; Test1.Address = "1 Leicester Road"; Test1.PhoneNumber = "07856681247"; Test1.DOB = DateTime.Parse("1988/07/08"); Test1.MemberID = 20; Test1.MedicalConditions = true; //set ThisMember to the test data AllMembers.ThisMember = Test1; //add the record PrimaryKey = AllMembers.Add(); //set the primary key of the test data Test1.MemberID = PrimaryKey; //find the record AllMembers.ThisMember.Find(PrimaryKey); //delete the record AllMembers.Delete(); //now find the record Boolean Found = AllMembers.ThisMember.Find(PrimaryKey); //test to see that the record was not found Assert.IsFalse(Found); }
public void InstanceOK() { //create an instance of the class we want to create clsMemberCollection AllMembers = new clsMemberCollection(); //test to see that it exists Assert.IsNotNull(AllMembers); }
public void ReportByDOBNoneFound() { //create an instance of the filtered data clsMemberCollection FilteredMembers = new clsMemberCollection(); //apply a DOB that doesnt exist FilteredMembers.ReportByDOB("2001/01/01"); //test to see that that there are no records Assert.AreEqual(0, FilteredMembers.Count); }
public void ReportByDOBMethodOK() { //create an instance of the class containing unflitered results clsMemberCollection AllMembers = new clsMemberCollection(); //create an instance of the filtered data clsMemberCollection FilteredMembers = new clsMemberCollection(); //apply a blank string (should return all records) FilteredMembers.ReportByDOB(""); Assert.AreEqual(AllMembers.Count, FilteredMembers.Count); }
protected void btnYes_Click(object sender, EventArgs e) { //create a new instance of the member collection clsMemberCollection AllMembers = new clsMemberCollection(); //find the record to delete AllMembers.ThisMember.Find(MemberID); //delete the record AllMembers.Delete(); //redirect back to the main page Response.Redirect("MemberList.aspx"); }
protected void bttnOK_Click(object sender, EventArgs e) { //create a new instance of clsMember clsMember AMember = new clsMember(); //capture all data for validation string FullName = txtbxFullName.Text; string Address = txtbxAddress.Text; string DOB = txtbxDOB.Text; string PhoneNumber = txtbxPhoneNumber.Text; //variable to store error messages string Error = ""; Error = AMember.Valid(FullName, Address, DOB, PhoneNumber); if (Error == "") { //capture all the data AMember.MemberID = MemberID; AMember.FullName = FullName; AMember.Address = Address; AMember.DOB = Convert.ToDateTime(DOB); AMember.PhoneNumber = PhoneNumber; AMember.MedicalConditions = chkbxMedicalConditions.Checked; //create a new instance of the Member collection clsMemberCollection AllMembers = new clsMemberCollection(); //if this is a new record then add the data if (MemberID == -1) { //set the ThisMember property AllMembers.ThisMember = AMember; //add the new record AllMembers.Add(); } else //otherwise it must be an update { //find the record to update AllMembers.ThisMember.Find(MemberID); //set the ThisMember property AllMembers.ThisMember = AMember; //update the record AllMembers.Update(); } //redirect back to the listpage Response.Redirect("MemberList.aspx"); } else { lblErrorMessage.Text = Error; } }
protected void bttnClear_Click(object sender, EventArgs e) { //create an instance of the Member collection clsMemberCollection Members = new clsMemberCollection(); Members.ReportByDOB(""); //clear any existing filter to tidy up the interface txtbxDOB.Text = ""; lstMemberList.DataValueField = "MemberID"; //set the name of the field to display lstMemberList.DataTextField = "FullName"; //bind the data to the list lstMemberList.DataBind(); }
protected void bttnApply_Click(object sender, EventArgs e) { //create an instance of the Member collection clsMemberCollection Members = new clsMemberCollection(); Members.ReportByDOB(txtbxDOB.Text); lstMemberList.DataSource = Members.MemberList; //set the name of the primary key lstMemberList.DataValueField = "MemberID"; //set the name of the field to display lstMemberList.DataTextField = "FullName"; //bind the data to the list lstMemberList.DataBind(); }
void DisplayMember() { //create an instance of the member collection clsMemberCollection Members = new clsMemberCollection(); //search for the record in order to update Members.ThisMember.Find(MemberID); //dispaly the data for this record txtbxMemberID.Text = Members.ThisMember.MemberID.ToString(); txtbxFullName.Text = Members.ThisMember.FullName; txtbxAddress.Text = Members.ThisMember.Address; txtbxDOB.Text = Members.ThisMember.DOB.ToString(); txtbxPhoneNumber.Text = Members.ThisMember.PhoneNumber.ToString(); chkbxMedicalConditions.Checked = Members.ThisMember.MedicalConditions; }
public void ThisMemberPropertyOK() { //create an instance of the class we want to create clsMemberCollection Test = new clsMemberCollection(); //create some test data to assign to the property clsMember Test1 = new clsMember(); //set the properties of the test object Test1.FullName = "Sofyan Koultouma"; Test1.Address = "1 Leicester Road"; Test1.PhoneNumber = "07856681247"; Test1.DOB = DateTime.Parse("1998/07/08"); Test1.MemberID = 10; Test1.MedicalConditions = false; //asign the data to the property Test.ThisMember = Test1; //test to see that the two values are the same Assert.AreEqual(Test.ThisMember, Test1); }
public void UpdateMethodOK() { //create an instance of the class we want to create clsMemberCollection AllMembers = new clsMemberCollection(); //create an item of test data clsMember Test1 = new clsMember(); //var to store the primary key Int32 PrimaryKey = 0; //set its properties Test1.FullName = "Sofyan Ronaldo"; Test1.Address = "1 Leicester Road"; Test1.PhoneNumber = "07745984535"; Test1.DOB = DateTime.Parse("1988/07/08"); Test1.MedicalConditions = true; //set ThisMember to the test data AllMembers.ThisMember = Test1; //set the primary key of the test data PrimaryKey = AllMembers.Add(); //set the primary key of the test data Test1.MemberID = PrimaryKey; //modify the test data Test1.FullName = "Cristiano Ronaldo"; Test1.Address = "1 London Road"; Test1.PhoneNumber = "07405610874"; Test1.DOB = DateTime.Parse("1978/07/08"); Test1.MedicalConditions = true; //set the record based on the new test data AllMembers.ThisMember = Test1; //update the record AllMembers.Update(); //fimd the record AllMembers.ThisMember.Find(PrimaryKey); //test to see ThisMember matches the test data Assert.AreEqual(AllMembers.ThisMember, Test1); // }
protected void Page_Load(object sender, EventArgs e) { //if this is the first time the page is displayed if (IsPostBack == false) { //update the list box DisplayMembers(); } void DisplayMembers() { //create an instance of the Member collection clsMemberCollection AllMembers = new clsMemberCollection(); //set the data source of the list of Members in the collection lstMemberList.DataSource = AllMembers.MemberList; //set the name of the primary key lstMemberList.DataValueField = "MemberID"; //set the data to display lstMemberList.DataTextField = "FullName"; //bind the data to the list lstMemberList.DataBind(); } }