예제 #1
0
        public void UpdateMethodOK()
        {
            clsCustomerCollection AllCustomers = new clsCustomerCollection();
            clscustomer           TestItem     = new clscustomer();
            Int32 PrimaryKey = 0;

            TestItem.Registered = true;
            TestItem.DOB        = Convert.ToDateTime("16/08/1999");
            TestItem.Name       = "Rushil";
            TestItem.Email      = "Ramesh";
            TestItem.Address    = "60, Rainworth road, LE5 4QE";
            TestItem.CustomerNo = 1;

            AllCustomers.ThisCustomer = TestItem;
            PrimaryKey          = AllCustomers.Add();
            TestItem.CustomerNo = PrimaryKey;

            TestItem.Registered = false;
            TestItem.DOB        = Convert.ToDateTime("16/08/1999");
            TestItem.Name       = "John";
            TestItem.Email      = "Steve";
            TestItem.Address    = "64, Worth road, LE7 4WE";
            TestItem.CustomerNo = 10;

            AllCustomers.ThisCustomer = TestItem;
            AllCustomers.Update();
            AllCustomers.ThisCustomer.Find(PrimaryKey);
            Assert.AreEqual(AllCustomers.ThisCustomer, TestItem);
        }
예제 #2
0
        public void ValidMethodOK()
        {
            clscustomer Acustomer = new clscustomer();
            String      Error     = "";

            Error = Acustomer.Valid(Name, Email, DOB, Address);
            Assert.AreEqual(Error, "");
        }
예제 #3
0
        public void TestMethod1()
        {
            //create an instance of the class we want to create
            clscustomer Acustomer = new clscustomer();

            //test to see that this exists
            Assert.IsNotNull(Acustomer);
        }
예제 #4
0
        public void DOBPropertyOK()
        {
            //create an instance of the class we want to create
            clscustomer Acustomer = new clscustomer();
            //create some test data to assign to the property
            DateTime TestData = DateTime.Now.Date;

            //assign the data to the property
            Acustomer.DOB = TestData;
            //test to see that the two values are the same
            Assert.AreEqual(Acustomer.DOB, TestData);
        }
예제 #5
0
        public void EmailPropertyOK()
        {
            //create an instance of the class we want to create
            clscustomer Acustomer = new clscustomer();
            //create some test data to assign to the property
            string TestData = "*****@*****.**";

            //assign the data to the property
            Acustomer.Email = TestData;
            //test to see that the two values are the same
            Assert.AreEqual(Acustomer.Email, TestData);
        }
예제 #6
0
        public void NamePropertyOK()
        {
            //create an instance of the class we want to create
            clscustomer Acustomer = new clscustomer();
            //create some test data to assign to the property
            string TestData = "Abi Sunn";

            //assign the data to the property
            Acustomer.Name = TestData;
            //test to see that the two values are the same
            Assert.AreEqual(Acustomer.Name, TestData);
        }
예제 #7
0
        public void CustomerNoPropertyOK()
        {
            //create an instance of the class we want to create
            clscustomer Acustomer = new clscustomer();
            //create some test data to assign to the property
            Int32 TestData = 1;

            //assign the data to the property
            Acustomer.CustomerNo = TestData;
            //test to see that the two values are the same
            Assert.AreEqual(Acustomer.CustomerNo, TestData);
        }
예제 #8
0
        public void AddressPropertyOK()
        {
            //create an instance of the class we want to create
            clscustomer Acustomer = new clscustomer();
            //create some test data to assign to the property
            string TestData = "60, Gate road, GA6 9PE";

            //assign the data to the property
            Acustomer.Address = TestData;
            //test to see that the two values are the same
            Assert.AreEqual(Acustomer.Address, TestData);
        }
예제 #9
0
        public void RegisteredPropertyOK()
        {
            //create an instance of the class we want to create
            clscustomer Acustomer = new clscustomer();
            //create some test data to assign to the property
            bool TestData = true;

            //assign the data to the property
            Acustomer.Registered = TestData;
            //test to see that the two values are the same
            Assert.AreEqual(Acustomer.Registered, TestData);
        }
예제 #10
0
        public void FindMethodOK()
        {
            //create an instance of the class we eant to create
            clscustomer Acustomer = new clscustomer();
            //Bollean variable to store the results of the validation
            Boolean Found = false;
            //create some test data to use with the method
            Int32 CustomerNo = 1;

            //invoke the method
            Found = Acustomer.Find(CustomerNo);
            //test to see if the result is true
            Assert.IsTrue(Found);
        }
예제 #11
0
        public void AddressMinPlusOne()
        {
            //create an instance of the class we want to create
            clscustomer Acustomer = new clscustomer();
            //string variable to store any error message
            String Error = "";
            //create some test data to pass to the method
            string Address = "aa"; //this should be ok

            //invoke the method
            Error = Acustomer.Valid(Name, Email, DOB, Address);
            //test to see that the result is correct
            Assert.AreEqual(Error, "");
        }
예제 #12
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //create a new instance of the class
        clscustomer Acustomer = new clscustomer();

        //get the data from the session object
        Acustomer = (clscustomer)Session["Acustomer"];
        //display the name on the page
        Response.Write(Acustomer.CustomerNo);
        Response.Write(Acustomer.Name);
        Response.Write(Acustomer.Email);
        Response.Write(Acustomer.DOB);
        Response.Write(Acustomer.Address);
    }
예제 #13
0
        public void EmailMaxPlusOne()
        {
            //create an instance of the class we want to create
            clscustomer Acustomer = new clscustomer();
            //string variable to store any error message
            String Error = "";
            //create some test data to pass to the method
            string Email = ""; //this should fail

            Email = Email.PadRight(51, 'a');
            //invoke the method
            Error = Acustomer.Valid(Name, Email, DOB, Address);
            //test to see that the result is correct
            Assert.AreNotEqual(Error, "");
        }
예제 #14
0
        public void DOBInvalidData()
        {
            //create an instance of the class we want to create
            clscustomer Acustomer = new clscustomer();
            //string variable to store any error message
            String Error = "";
            //create some test data to pass to the method
            string DOB = "This is not a date!"; //this should fail

            Name = Name.PadRight(500, 'a');     //this should fail
            //invoke the method
            Error = Acustomer.Valid(Name, Email, DOB, Address);
            //test to see that the result is correct
            Assert.AreNotEqual(Error, "");
        }
예제 #15
0
        public void DOBMax()
        {
            //create an instance of the class we want to create
            clscustomer Acustomer = new clscustomer();
            //string variable to store any error message
            String Error = "";
            //create a variable to store the test date data
            DateTime TestDate;

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

            //invoke the method
            Error = Acustomer.Valid(Name, Email, DOB, Address);
            //test to see that the result is correct
            Assert.AreEqual(Error, "");
        }
예제 #16
0
    protected void btnOK_Click(object sender, EventArgs e)
    {
        //create a new instance of clscustomer
        clscustomer Acustomer = new clscustomer();
        //capture the details
        string Name    = txtName.Text;
        string Email   = txtEmail.Text;
        string DOB     = txtDOB.Text;
        string Address = txtAddress.Text;
        string Error   = "";

        Error = Acustomer.Valid(Name, Email, DOB, Address);
        if (Error == "")
        {
            Acustomer.CustomerNo = Convert.ToInt32(CustomerNo);
            Acustomer.Name       = Name;
            Acustomer.Email      = Email;
            Acustomer.DOB        = Convert.ToDateTime(DOB);
            Acustomer.Address    = Address;
            Acustomer.Registered = chkRegistered.Checked;
            clsCustomerCollection CustomerList = new clsCustomerCollection();
            if (CustomerNo == -1)
            {
                CustomerList.ThisCustomer = Acustomer;
                CustomerList.Add();
            }
            else
            {
                CustomerList.ThisCustomer.Find(CustomerNo);
                CustomerList.ThisCustomer = Acustomer;
                CustomerList.Update();
            }
            Response.Redirect("CustomerList.aspx");

            //CustomerList.ThisCustomer = Acustomer;
            //CustomerList.Add();
            //Response.Redirect("CustomerList.aspx");
        }
        else
        {
            lblerror.Text = Error;
        }
    }
예제 #17
0
        public void ThisCustomerPropertyOK()
        {
            clsCustomerCollection AllCustomers = new clsCustomerCollection();

            clscustomer TestCustomer = new clscustomer();

            TestCustomer.Registered = true;
            TestCustomer.DOB        = Convert.ToDateTime("16/08/1999");
            TestCustomer.Name       = "Rushil";
            TestCustomer.Email      = "Ramesh";
            TestCustomer.Address    = "60, Rainworth road, LE5 4QE";
            TestCustomer.CustomerNo = 1;

            AllCustomers.ThisCustomer = TestCustomer;



            Assert.AreEqual(AllCustomers.ThisCustomer, TestCustomer);
        }
예제 #18
0
        public void TestCustomerNoFound()
        {
            //create an instance of the class we eant to create
            clscustomer Acustomer = new clscustomer();
            //boolean varaible to store the result of the search
            Boolean Found = false;
            //boolean varaible to record if data is OK
            Boolean OK = true;
            //create some test data to use with the method
            Int32 CustomerNo = 1;

            //invoke the method
            Found = Acustomer.Find(CustomerNo);
            //check the customer no
            if (Acustomer.CustomerNo != 1)
            {
                OK = false;
            }
            //test to see that the result is correct
            Assert.IsTrue(OK);
        }
예제 #19
0
        public void AddMethodOK()
        {
            //create an instance fof the class we want to create
            clsCustomerCollection AllCustomers = new clsCustomerCollection();
            //create some test data to assign to the property
            clscustomer TestItem   = new clscustomer();
            Int32       Primarykey = 0;

            TestItem.Registered = true;
            TestItem.DOB        = Convert.ToDateTime("16/08/1999");
            TestItem.Name       = "Rushil";
            TestItem.Email      = "Ramesh";
            TestItem.Address    = "60, Rainworth road, LE5 4QE";
            TestItem.CustomerNo = 1;

            AllCustomers.ThisCustomer = TestItem;
            Primarykey          = AllCustomers.Add();
            TestItem.CustomerNo = Primarykey;
            AllCustomers.ThisCustomer.Find(Primarykey);
            Assert.AreEqual(AllCustomers.ThisCustomer, TestItem);
        }
예제 #20
0
        public void DeleteMethodOK()
        {
            clsCustomerCollection AllCustomers = new clsCustomerCollection();
            clscustomer           TestItem     = new clscustomer();
            Int32 PrimaryKey = 0;

            TestItem.Registered       = true;
            TestItem.DOB              = Convert.ToDateTime("16/08/1999");
            TestItem.Name             = "Rushil";
            TestItem.Email            = "Ramesh";
            TestItem.Address          = "60, Rainworth road, LE5 4QE";
            TestItem.CustomerNo       = 1;
            AllCustomers.ThisCustomer = TestItem;
            PrimaryKey          = AllCustomers.Add();
            TestItem.CustomerNo = PrimaryKey;
            AllCustomers.ThisCustomer.Find(PrimaryKey);
            AllCustomers.Delete();
            Boolean Found = AllCustomers.ThisCustomer.Find(PrimaryKey);

            Assert.IsFalse(Found);
        }
예제 #21
0
        public void TestDOBFound()
        {
            //create an instance of the class we want to create
            clscustomer Acustomer = new clscustomer();
            //Bolean variable to store the results of the search
            Boolean Found = false;
            //boolean variable to record if data is OK
            Boolean OK = true;
            //create some test data to use with the method
            Int32 CustomerNo = 1;

            //invoke the methods
            Found = Acustomer.Find(CustomerNo);
            //check the customer no
            if (Acustomer.DOB != Convert.ToDateTime("15/01/1998"))
            {
                OK = false;
            }
            //test to see if the result is true
            Assert.IsTrue(OK);
        }
예제 #22
0
        public void TestRegisteredFound()
        {
            //create an instance of the class we want to create
            clscustomer Acustomer = new clscustomer();
            //Bolean variable to store the results of the serach
            Boolean Found = false;
            //boolean variable to record if data is OK
            Boolean OK = true;
            //create some test data to use with the method
            Int32 CustomerNo = 1;

            //invoke the methods
            Found = Acustomer.Find(CustomerNo);
            //check the customer no
            if (Acustomer.Registered != true)
            {
                OK = false;
            }
            //test to see if the result is true
            Assert.IsFalse(OK);
        }
예제 #23
0
        public void ListAndCountOK()
        {
            clsCustomerCollection AllCustomers = new clsCustomerCollection();

            List <clscustomer> TestList = new List <clscustomer>();
            clscustomer        TestItem = new clscustomer();

            TestItem.Registered = true;
            TestItem.DOB        = Convert.ToDateTime("16/08/1999");
            TestItem.Name       = "Rushil";
            TestItem.Email      = "Ramesh";
            TestItem.Address    = "60, Rainworth road, LE5 4QE";
            TestItem.CustomerNo = 1;

            TestList.Add(TestItem);

            AllCustomers.CustomerList = TestList;



            Assert.AreEqual(AllCustomers.Count, TestList.Count);
        }
예제 #24
0
    protected void btnFind_Click(object sender, EventArgs e)
    {
        //created an instance of the customer class
        clscustomer Acustomer = new clscustomer();
        //variable to store the primary key
        Int32 CustomerNo;
        //variable to tore the results of the find operation
        Boolean Found = false;

        //get the primary key entered by the user
        CustomerNo = Convert.ToInt32(txtCustomerNo.Text);
        //find the record
        Found = Acustomer.Find(CustomerNo);
        //if found
        if (Found == true)
        {
            //display the values of the properties in the form
            txtName.Text    = Acustomer.Name;
            txtEmail.Text   = Acustomer.Email;
            txtDOB.Text     = Acustomer.DOB.ToString();
            txtAddress.Text = Acustomer.Address;
        }
    }