示例#1
0
        public void DeleteMethodOK()
        {
            //Create an instance of the class we want to create
            clsCourseCollection AllCourses = new clsCourseCollection();
            //create the item of test data
            clsCourses TestItem = new clsCourses();
            //var to store the primary key
            Int32 PrimaryKey = 0;

            //set its properties
            TestItem.Available = true;
            TestItem.IDno      = 1;
            TestItem.Title     = "Web Development";
            TestItem.Category  = "Technology";
            TestItem.Tutor     = "R Sunderland";
            TestItem.LiveDate  = DateTime.Now.Date;
            TestItem.Price     = 180;
            //set ThisCourse to the test data
            AllCourses.ThisCourse = TestItem;
            //add the record
            PrimaryKey = AllCourses.Add();
            //set the primary key of the test data
            TestItem.IDno = PrimaryKey;
            //find the record
            AllCourses.ThisCourse.Find(PrimaryKey);
            //delete the record
            AllCourses.Delete();
            //now find the record
            Boolean Found = AllCourses.ThisCourse.Find(PrimaryKey);

            //test to see that the record was not found
            Assert.IsFalse(Found);
        }
示例#2
0
        public void ListAndCountOK()
        {
            //Create an instance of the class we want to create
            clsCourseCollection AllCourses = new clsCourseCollection();
            //create some test data to assign to the property
            //in this case the data needs to be a list of objects
            List <clsCourses> TestList = new List <clsCourses>();
            //add an item to the list
            //create the item of test data
            clsCourses TestItem = new clsCourses();

            //set its properties
            TestItem.Available = true;
            TestItem.IDno      = 1;
            TestItem.Title     = "Computing";
            TestItem.Category  = "Technology";
            TestItem.Tutor     = "D Lewis";
            TestItem.LiveDate  = DateTime.Now.Date;
            TestItem.Price     = 200;
            //add the item to the test list
            TestList.Add(TestItem);
            //assign the data to the property
            AllCourses.CourseList = TestList;
            //test to see that the two values are the same
            Assert.AreEqual(AllCourses.Count, TestList.Count);
        }
        public void InstanceOK()
        {
            //create an instance of the class we want to create
            clsCourses aCourse = new clsCourses();

            //test to see that it exists
            Assert.IsNotNull(aCourse);
        }
        public void TitleCourseOK()
        {//create an instance of the class we want to create
            clsCourses aCourse = new clsCourses();
            //create some test data to assign to the course
            String TestData = "Computer Science";

            //asign the data to the course
            aCourse.Title = TestData;
            //test to see that the two values are the same
            Assert.AreEqual(aCourse.Title, TestData);
        }
        public void CategoryCourseOK()
        {//create an instance of the class we want to create
            clsCourses aCourse = new clsCourses();
            //create some test data to assign to the course
            String TestData = "Technology";

            //asign the data to the course
            aCourse.Category = TestData;
            //test to see that the two values are the same
            Assert.AreEqual(aCourse.Category, TestData);
        }
        public void TutorCourseOK()
        {//create an instance of the class we want to create
            clsCourses aCourse = new clsCourses();
            //create some test data to assign to the course
            String TestData = "D Armstrong";

            //asign the data to the course
            aCourse.Tutor = TestData;
            //test to see that the two values are the same
            Assert.AreEqual(aCourse.Tutor, TestData);
        }
        public void LiveDateCourseOK()
        {
            //create an instance of the class we want to create
            clsCourses aCourse = new clsCourses();
            //create some test data to assign to the course
            DateTime TestData = DateTime.Now.Date;

            //assign the data to the course
            aCourse.LiveDate = TestData;
            //test to see that the two values are the same
            Assert.AreEqual(aCourse.LiveDate, TestData);
        }
        public void PriceCourseok()
        {
            //create an instance of the class we want to create
            clsCourses aCourse = new clsCourses();
            //create some test data to assign to the course
            decimal TestData = 00.00m;

            //assign the data to the  course
            aCourse.Price = TestData;
            //test to see that the two values are the same
            Assert.AreEqual(aCourse.Price, TestData);
        }
        public void ValidMethodOK()
        {
            //create an instance of the class we want to create
            clsCourses aCourse = new clsCourses();
            //string variable to store any error message
            String Error = "";

            //invoke the method
            Error = aCourse.Valid(Title, Category, Tutor, LiveDate, Price);
            //test to see that the result is correct
            Assert.AreEqual(Error, "");
        }
        public void IDCourseOK()
        {
            //create an instance of the class we want to create
            clsCourses aCourse = new clsCourses();
            //create some test data to assign to the course
            Int32 TestData = 1;

            //asign the data to the course
            aCourse.IDno = TestData;
            //test to see that the two values are the same
            Assert.AreEqual(aCourse.IDno, TestData);
        }
        public void AvailableCourseOK()
        {
            //create an instance of the class we want to create
            clsCourses aCourse = new clsCourses();
            //create some test data to assign to the property
            Boolean TestData = true;

            //assign the data to the  course
            aCourse.Available = TestData;
            //test to see that the two values are the same
            Assert.AreEqual(aCourse.Available, TestData);
        }
        public void PriceInvalidData()
        {
            //create an instance of the class we want to create
            clsCourses aCourse = new clsCourses();
            //string variable to store any error message
            String Error = "";
            //set the LiveDate to a non date value
            string Price = "this is not a decimal!";

            Error = aCourse.Valid(Title, Category, Tutor, LiveDate, Price);
            //test to see that the result is correct
            Assert.AreNotEqual(Error, "");
        }
        public void FindMethodOK()
        {
            //create an instance of the class we want to create
            clsCourses aCourse = new clsCourses();
            //boolean variable to store the result of the validation
            Boolean Found = false;
            //Create some test data to use with the method
            Int32 IDno = 1;

            //invoke the method
            Found = aCourse.Find(IDno);
            //Test to see that the result is correct
            Assert.IsTrue(Found);
        }
        public void TutorMaxPlusOne()
        {
            //create an instance of the class we want to create
            clsCourses aCourse = new clsCourses();
            //string variable to store any error message
            String Error = "";
            //create some test data to pass to the method
            string Tutor = "aaaaaaaaaaaaaaaaaaabbbbbbb";//this should fail

            //invoke the method
            Error = aCourse.Valid(Title, Category, Tutor, LiveDate, Price);
            //test to see that the result is correct
            Assert.AreNotEqual(Error, "");
        }
        public void LiveDateMin()
        {
            //create an instance of the class we want to create
            clsCourses aCourse = new clsCourses();
            //string variable to store any error message
            String Error = "";
            //create a variable to store the test date data
            DateTime TestDate;

            //set the date to todays date
            TestDate = DateTime.Now.Date;
            //convert the date variable to a string variable
            string LiveDate = TestDate.ToString();

            //invoke the method
            Error = aCourse.Valid(Title, Category, Tutor, LiveDate, Price);
            //test to see that the result is correct
            Assert.AreEqual(Error, "");
        }
        public void PriceMin()
        {
            //create an instance of the class we want to create
            clsCourses aCourse = new clsCourses();
            //string variable to store any error message
            String Error = "";
            //create a variable to store the test date data
            Decimal TestPrice;

            //set TestPrice to a value
            TestPrice = 00.00m;
            //convert the decimal variable to a string variable
            string Price = TestPrice.ToString();

            //invoke the method
            Error = aCourse.Valid(Title, Category, Tutor, LiveDate, Price);
            //test to see that the result is correct
            Assert.AreEqual(Error, "");
        }
示例#17
0
        public void ThisCoursePropertyOK()
        {
            //Create an instance of the class we want to create
            clsCourseCollection AllCourses = new clsCourseCollection();
            //create some test data to assign to the property
            clsCourses TestCourses = new clsCourses();

            //set the properties of the test object
            TestCourses.Available = true;
            TestCourses.IDno      = 1;
            TestCourses.Title     = "Computing";
            TestCourses.Category  = "Technology";
            TestCourses.Tutor     = "D Lewis";
            TestCourses.LiveDate  = DateTime.Now.Date;
            TestCourses.Price     = 200;
            //assign the data to the property
            AllCourses.ThisCourse = TestCourses;
            //test to see that the two values are the same
            Assert.AreEqual(AllCourses.ThisCourse, TestCourses);
        }
        public void TestCategoryFound()
        {
            //create an instance of the class we want to create
            clsCourses aCourse = new clsCourses();
            //boolean variable to store the result of the validation
            Boolean Found = false;
            //boolean variable to record if data is ok (assume it is)
            Boolean OK = true;
            //create some test data to use with the methods
            String Category = Convert.ToString("Technology");

            //invoke the method
            Found = aCourse.Find(1);
            //check the address no
            if (aCourse.Category != "Technology")
            {
                OK = false;
            }
            //test to see that the result is correct
            Assert.IsTrue(OK);
        }
        public void TestAvailableFound()
        {
            //create an instance of the class we want to create
            clsCourses aCourse = new clsCourses();
            //boolean variable to store the result of the validation
            Boolean Found = false;
            //boolean variable to record if data is ok (assume it is)
            Boolean OK = true;
            //create some test data to use with the methods
            Boolean Available = Convert.ToBoolean(true);

            //invoke the method
            Found = aCourse.Find(1);
            //check the address no
            if (aCourse.Available != true)
            {
                OK = false;
            }
            //test to see that the result is correct
            Assert.IsTrue(OK);
        }
示例#20
0
        public void UpdateMethodOK()
        {
            //Create an instance of the class we want to create
            clsCourseCollection AllCourses = new clsCourseCollection();
            //create the item of test data
            clsCourses TestItem = new clsCourses();
            //var to store the primary key
            Int32 PrimaryKey = 0;

            //set its properties
            TestItem.Available = true;
            TestItem.IDno      = 1;
            TestItem.Title     = "Web Development";
            TestItem.Category  = "Technology";
            TestItem.Tutor     = "R Sunderland";
            TestItem.LiveDate  = DateTime.Now.Date;
            TestItem.Price     = 180;
            //set ThisCourse to the test data
            AllCourses.ThisCourse = TestItem;
            //add the record
            PrimaryKey = AllCourses.Add();
            //set the primary key of the test data
            TestItem.IDno = PrimaryKey;
            //modify the test data
            TestItem.Available = false;
            TestItem.IDno      = 11;
            TestItem.Title     = "Front-end Web Development";
            TestItem.Category  = "Technology";
            TestItem.Tutor     = "S Sunderland";
            TestItem.LiveDate  = DateTime.Now.Date;
            TestItem.Price     = 150;
            //set the record based on the new test data
            AllCourses.ThisCourse = TestItem;
            //update the record
            AllCourses.Update();
            //find the record
            AllCourses.ThisCourse.Find(PrimaryKey);
            //test to see ThisCourse matches the test data
            Assert.AreEqual(AllCourses.ThisCourse, TestItem);
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        //create a new instance of clsCourses
        clsCourses aCourse = new clsCourses();

        //get the data from the session object
        aCourse = (clsCourses)Session["aCourse"];
        //display the ID for this entry
        Response.Write(aCourse.IDno);
        //display the Title for this entry
        Response.Write(aCourse.Title);
        //display the Category for this entry
        Response.Write(aCourse.Category);
        //display the Tutor for this entry
        Response.Write(aCourse.Tutor);
        //display the LiveDate for this entry
        Response.Write(aCourse.LiveDate);
        //display the Available for this entry
        Response.Write(aCourse.Available);
        //display the Price for this entry
        Response.Write(aCourse.Price);
    }
        public void TestLiveDateFound()
        {
            //create an instance of the class we want to create
            clsCourses aCourse = new clsCourses();
            //boolean variable to store the result of the validation
            Boolean Found = false;
            //boolean variable to record if data is ok (assume it is)
            Boolean OK = true;
            //create some test data to use with the methods
            DateTime LiveDate = Convert.ToDateTime("01/01/2020");

            //DateTime LiveDate = 01/01/2020;
            //invoke the method
            Found = aCourse.Find(1);
            //check the address no
            if (aCourse.LiveDate != Convert.ToDateTime("01/01/2020"))
            {
                OK = false;
            }
            //test to see that the result is correct
            Assert.IsTrue(OK);
        }
示例#23
0
    protected void Find_Click(object sender, EventArgs e)
    {
        //create a new instance of clsCourses
        clsCourses aCourse = new clsCourses();
        //variable to store the primary key
        Int32 IDno;
        //variable to store the result of the find operation
        Boolean Found = false;

        //get the primary key entered by the user
        IDno = Convert.ToInt32(txtIDno.Text);
        //find the record
        Found = aCourse.Find(IDno);
        //if found
        if (Found == true)
        {
            //display the values of the properties in the form
            txtIDno.Text           = aCourse.IDno.ToString();
            txtTitleCourse.Text    = aCourse.Title;
            txtCategoryCourse.Text = aCourse.Category;
            txtTutorCourse.Text    = aCourse.Tutor;
            if (aCourse.LiveDate.Day < 10 & aCourse.LiveDate.Month < 10)
            {
                txtLiveDateCourse.Text = "0" + aCourse.LiveDate.Day + "/0" + aCourse.LiveDate.Month + "/" + aCourse.LiveDate.Year;
            }
            else if (aCourse.LiveDate.Day < 10)
            {
                txtLiveDateCourse.Text = "0" + aCourse.LiveDate.Day + "/" + aCourse.LiveDate.Month + "/" + aCourse.LiveDate.Year;
            }
            else if (aCourse.LiveDate.Month < 10)
            {
                txtLiveDateCourse.Text = aCourse.LiveDate.Day + "/0" + aCourse.LiveDate.Month + "/" + aCourse.LiveDate.Year;
            }
            Available.Text      = aCourse.Available.ToString();
            txtpriceCourse.Text = aCourse.Price.ToString();
        }
    }
示例#24
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        lblError.Text = "";
        //create a new instance of clsCourses
        clsCourses aCourse = new clsCourses();
        //capture the CourseTitle
        string Title = txtTitleCourse.Text;
        //capture the  courseCategory
        string Category = txtCategoryCourse.Text;
        //capture the  courseTutor
        string Tutor = txtTutorCourse.Text;
        //capture the courseLiveDate
        string LiveDate = txtLiveDateCourse.Text;
        //capture the coursePrice
        string Price = txtpriceCourse.Text;
        //variable to store any error messages
        string Error = "";

        //validate the data
        Error = aCourse.Valid(Title, Category, Tutor, LiveDate, Price);
        if (Error == "")
        {
            //capture the IDno
            aCourse.IDno = IDno;
            //capture the Title
            aCourse.Title = Title;
            //capture the Category
            aCourse.Category = Category;
            //capture the Tutor
            aCourse.Tutor = Tutor;
            //capture the LiveDate
            aCourse.LiveDate = Convert.ToDateTime(LiveDate);
            //capture the Price
            aCourse.Price = Convert.ToDecimal(Price);
            //capture Available
            aCourse.Available = Available.Checked;
            //create a new instance of the address collection
            clsCourseCollection courseList = new clsCourseCollection();

            //if this is a new record i.e IDno = -1 then add the data
            if (IDno == -1)
            {
                //set the ThisCourse property
                courseList.ThisCourse = aCourse;
                //add the new record
                courseList.Add();
            }
            //otherwise it must be an update
            else
            {
                //find the record to update
                courseList.ThisCourse.Find(IDno);
                //set the ThisCourse property
                courseList.ThisCourse = aCourse;
                //update the record
                courseList.Update();
            }
            //redirect back to the listpage
            Response.Redirect("CourseList.aspx");
        }
        else
        {
            //display the error message
            lblError.Text = Error;
        }
    }