Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
    //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();
    }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
    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();
    }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
    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();
    }
Exemplo n.º 11
0
    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();
    }
Exemplo n.º 12
0
        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);
        }
Exemplo n.º 13
0
    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;
        }
    }
Exemplo n.º 14
0
        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);
        }
Exemplo n.º 15
0
        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);
        }