public void ReportByDepartmentNameTestDataFound() { //create an instance of the filtered data clsDepartmentCollection FilteredDepartment = new clsDepartmentCollection(); //var to store outcome Boolean OK = true; //apply a Name that doesn't exist FilteredDepartment.ReportByDepartmentName("Head Office"); //check that the correct number of records are found if (FilteredDepartment.Count == 1) { //check that the first record is ID 1 if (FilteredDepartment.DepartmentList[0].Dep_ID != 4) { OK = false; } } else { OK = false; } //test to see that there are no records Assert.IsTrue(OK); }
public void DeleteMethodOK() { //create an instance of the class we want to create clsDepartmentCollection AllDepartments = new clsDepartmentCollection(); //create the item of test data clsDepartment TestDepartment = new clsDepartment(); //var to store the primary key Int32 PrimaryKey = 20; //set its properties TestDepartment.Dep_Name = "Store"; TestDepartment.Dep_Location = "Liverpool"; TestDepartment.No_Employees = 44; //set ThisAddress to the test data AllDepartments.ThisDepartment = TestDepartment; //add the record PrimaryKey = AllDepartments.Add(); //set the primary key of the test data TestDepartment.Dep_ID = PrimaryKey; //find the record AllDepartments.ThisDepartment.Find(PrimaryKey); //delete the record AllDepartments.Delete(); //now find the record Boolean Found = AllDepartments.ThisDepartment.Find(PrimaryKey); //test to see that the record was not found Assert.IsFalse(Found); }
public void UpdateMethodOK() { //create an instance of the class we want to create clsDepartmentCollection AllDepartments = new clsDepartmentCollection(); //create the item of test data clsDepartment TestDepartment = new clsDepartment(); //var to store the primary key Int32 PrimaryKey = 0; //set its properties TestDepartment.Dep_Name = "Store"; TestDepartment.Dep_Location = "Liverpool"; TestDepartment.No_Employees = 44; //set ThisAddress to the test data AllDepartments.ThisDepartment = TestDepartment; //add the record PrimaryKey = AllDepartments.Add(); //set the primary key of the test data TestDepartment.Dep_ID = PrimaryKey; //modify the test data TestDepartment.Dep_Name = "Stores"; TestDepartment.Dep_Location = "Liverpool"; TestDepartment.No_Employees = 45; //set the record based on the new test data AllDepartments.ThisDepartment = TestDepartment; //update the record AllDepartments.Update(); //find the record AllDepartments.ThisDepartment.Find(PrimaryKey); //test to see ThisAddress matches the test data Assert.AreEqual(AllDepartments.ThisDepartment, TestDepartment); }
public void InstanceOK() { //creat a instance of the class we want to create clsDepartmentCollection AllDepartments = new clsDepartmentCollection(); //test to see that it exists Assert.IsNotNull(AllDepartments); }
//event handler for the apply button protected void btnApply_Click(object sender, EventArgs e) { clsDepartmentCollection departments = new clsDepartmentCollection(); departments.ReportByDepartmentName(txtName.Text); lstdepartment.DataSource = departments.DepartmentList; lstdepartment.DataValueField = "dep_ID"; lstdepartment.DataTextField = "dep_Name"; lstdepartment.DataBind(); }
public void ReportByDepartmentNameNoneFound() { //create an instance of the filtered data clsDepartmentCollection FilteredDepartment = new clsDepartmentCollection(); //apply a post code that doesn't exist string test = "snggfs"; FilteredDepartment.ReportByDepartmentName(test); //test to see that there are no records Assert.AreEqual(0, FilteredDepartment.Count); }
void DisplayDepartment() { clsDepartmentCollection DepartmentList = new clsDepartmentCollection(); DepartmentList.ThisDepartment.Find(dep_ID); //display the data txtdep_ID.Text = DepartmentList.ThisDepartment.Dep_ID.ToString(); txtdep_Name.Text = DepartmentList.ThisDepartment.Dep_Name; txtdep_Location.Text = DepartmentList.ThisDepartment.Dep_Location; txtno_Employee.Text = DepartmentList.ThisDepartment.No_Employees.ToString(); }
public void CountPropertyOK() { //create an instance of the class we want to create clsDepartmentCollection AllDepartments = new clsDepartmentCollection(); //create some test data to assign to the property Int32 SomeCount = 10; //assign the data to the property AllDepartments.Count = SomeCount; //test to see that the two values are the same Assert.AreNotEqual(AllDepartments.Count, SomeCount); }
public void ReportByDepartmentNameMethodOK() { //create an instance of the class containing unfiltered results clsDepartmentCollection AllDepartments = new clsDepartmentCollection(); //create an instance of the filtered data clsDepartmentCollection FilteredDepartment = new clsDepartmentCollection(); //apply a blank string (should return all records); FilteredDepartment.ReportByDepartmentName(""); //test to see that the two values are the same Assert.AreEqual(FilteredDepartment.Count, AllDepartments.Count); }
void DeleteDepartment() { //function to delete the selected record //create a new instance of the address book clsDepartmentCollection departmentBook = new clsDepartmentCollection(); //find the record to delete departmentBook.ThisDepartment.Find(dep_ID); //delete the record departmentBook.Delete(); }
void DisplayName() { //create an instance of the Employee Collection clsDepartmentCollection Names = new clsDepartmentCollection(); //set the data source to the list of names in the collection lstdepartment.DataSource = Names.DepartmentList; //set the name of the primary key lstdepartment.DataValueField = "dep_ID"; //set the data field to display lstdepartment.DataTextField = "dep_Name"; //bind the data to the list lstdepartment.DataBind(); }
public void ThisDepartmentPropertyOK() { //create an instance of the class we want to create clsDepartmentCollection AllDepartments = new clsDepartmentCollection(); //create some test data to assign to the property clsDepartment TestDepartment = new clsDepartment(); //set the properties of the test object TestDepartment.Dep_ID = 6; TestDepartment.Dep_Name = "Media"; TestDepartment.Dep_Location = "Suffolk"; TestDepartment.No_Employees = 23; //assign the data to the property AllDepartments.ThisDepartment = TestDepartment; //test to see that the two values are the same Assert.AreEqual(AllDepartments.ThisDepartment, TestDepartment); }
protected void btnOK_Click(object sender, EventArgs e) { clsDepartment ADepartment = new clsDepartment(); string dep_Location = txtdep_Location.Text; string dep_Name = txtdep_Name.Text; string no_Employees = txtno_Employee.Text; string Error = ""; Error = ADepartment.Valid(dep_Name, dep_Location, no_Employees); if (Error == "") { ADepartment.Dep_ID = dep_ID; ADepartment.Dep_Name = dep_Name; ADepartment.Dep_Location = dep_Location; ADepartment.No_Employees = Convert.ToInt32(no_Employees); clsDepartmentCollection DepartmentList = new clsDepartmentCollection(); if (Convert.ToInt32(dep_ID) == -1) { DepartmentList.ThisDepartment = ADepartment; DepartmentList.Add(); } else { DepartmentList.ThisDepartment.Find(Convert.ToInt32(dep_ID)); DepartmentList.ThisDepartment = ADepartment; DepartmentList.Update(); } Response.Redirect("DefaultDepartment.aspx"); } else { lblError.Text = Error; } }
public void ListAndCountOK() { //create an instance of the class we want to create clsDepartmentCollection AllDepartments = new clsDepartmentCollection(); //create some test data to assign to the property //in this case the data needs to be a list of objects List <clsDepartment> TestList = new List <clsDepartment>(); //add an item to the list //create the item of test data clsDepartment TestDepartment = new clsDepartment(); //set its properties TestDepartment.Dep_ID = 7; TestDepartment.Dep_Name = "Store"; TestDepartment.Dep_Location = "Liverpool"; TestDepartment.No_Employees = 44; //add the item to the test list TestList.Add(TestDepartment); //assign the data to the property AllDepartments.DepartmentList = TestList; //test to see that the two values are the same Assert.AreEqual(AllDepartments.Count, TestList.Count); }
public void AddMethodOK() { //create an instance of the class we want to create clsDepartmentCollection AllDepartments = new clsDepartmentCollection();; //create the item of test data clsDepartment TestDepartment = new clsDepartment(); //var to store the primary key Int32 PrimaryKey = 12; //set its properties TestDepartment.Dep_Name = "Store"; TestDepartment.Dep_Location = "Liverpool"; TestDepartment.No_Employees = 44; //set ThisEmployee to the test data AllDepartments.ThisDepartment = TestDepartment; //add the record AllDepartments.Add(); //set the primary key of the test data //find the record AllDepartments.ThisDepartment.Find(PrimaryKey); //test to see that the two values are the same Assert.AreEqual(AllDepartments.ThisDepartment, TestDepartment); }