Пример #1
0
        public void ValidMethodOK()
        {
            //create an instance of the class
            clsDepartment AnDepartment = new clsDepartment();
            //string variable to store any error message
            String Error = "";

            //invoke the method
            Error = AnDepartment.Valid(Dep_Name, Dep_Location, No_Employees);
            //test to see that the result is correct
            Assert.AreEqual(Error, "");
        }
Пример #2
0
        public void NumberOfEmployeesIncorrectFormat()
        {
            //create an instance of the class we want to create
            clsDepartment AnDepartment = new clsDepartment();
            //string variable to store any error message
            String Error = "";
            //create some test data to pass to the method
            String No_Employees = "two";

            //invoke the method
            Error = AnDepartment.Valid(Dep_Name, Dep_Location, No_Employees);
            //test to see that the result is correct
            Assert.AreNotEqual(Error, "");
        }
Пример #3
0
        public void NumberOfEmployeesMid()
        {
            //create an instance of the class we want to create
            clsDepartment AnDepartment = new clsDepartment();
            //string variable to store any error message
            String Error = "";
            //create some test data to pass to the method
            int No_Employees = 100; //this should be ok

            //invoke the method
            Error = AnDepartment.Valid(Dep_Name, Dep_Location, Convert.ToString(No_Employees));
            //test to see that the result is correct
            Assert.AreEqual(Error, "");
        }
Пример #4
0
        public void DepartmentLocationMaxPlusOne()
        {
            //create an instance of the class we want to create
            clsDepartment AnDepartment = new clsDepartment();
            //string variable to store any error message
            String Error = "";
            //create some test data to pass to the method
            string Dep_Location = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; //this should fail

            //invoke the method
            Error = AnDepartment.Valid(Dep_Name, Dep_Location, No_Employees);
            //test to see that the result is correct
            Assert.AreNotEqual(Error, "");
        }
Пример #5
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;
        }
    }