Beispiel #1
0
        public void FilterbyEmailTestDataFound()
        {
            //create an instance of the filtered data
            clsContactUsCollection FilteredContacts = new clsContactUsCollection(" ");
            //var to store outcome
            Boolean OK = true;

            //apply a primary key value
            FilteredContacts.FilterbyEmail("*****@*****.**");
            //check the correct number of records are found
            if (FilteredContacts.Count == 12)
            {
                //check the first record is ID 2
                if (FilteredContacts.ContactList[0].ContactId != 2000)
                {
                    OK = false;
                }
                // check that the first record is ID
                if (FilteredContacts.ContactList[9].ContactId != 2013)
                {
                    OK = false;
                }
            }
            else
            {
                OK = false;
            }

            //test to see there are records
            Assert.IsTrue(OK);
        }
Beispiel #2
0
        public void DeleteMethodOK()
        {
            //create an instance of the class we want to create
            clsContactUsCollection AContact = new clsContactUsCollection("Fbloggs");
            //create an instance of test data
            clsContactUs TestItem = new clsContactUs();
            //var to store primary key
            Int32 PK = 0;

            //set the properties
            //TestItem.CustomerID = 3;
            TestItem.Email   = "[email protected]";
            TestItem.Name    = "Ayub Osman1";
            TestItem.Message = " I Loved the meal. Thanks !1 ";
            //set ThisCustomer to validate test data
            AContact.ThisContact = TestItem;
            //add the record
            PK = AContact.Add();
            //set primary key of test data
            TestItem.ContactId = PK;
            //find the record
            AContact.ThisContact.Find(PK);
            //delete the record
            AContact.Delete();
            //now find the record
            Boolean Found = AContact.ThisContact.Find(PK);

            //test to see that it exists
            Assert.IsFalse(Found);
        }
Beispiel #3
0
        public void UpdateMethodOK()
        {
            //create an instance of the class we want to create
            clsContactUsCollection AContact = new clsContactUsCollection("Fbloggs");
            //create an instance of test data
            clsContactUs TestItem = new clsContactUs();
            //var to store primary key
            Int32 PK = 0;

            //set the properties
            TestItem.Email   = "[email protected]";
            TestItem.Name    = "Ayub Osman2";
            TestItem.Message = " I Loved the meal. Thanks !2 ";
            //set ThisCustomer to validate test data
            AContact.ThisContact = TestItem;
            //add the record
            PK = AContact.Add();
            //set primary key of test data
            TestItem.ContactId = PK;
            //modify the record
            TestItem.Email   = "[email protected]";
            TestItem.Name    = "Ayub Osman1";
            TestItem.Message = " I Loved the meal. Thanks !1 ";
            //set the record based on the new record
            AContact.ThisContact = TestItem;
            //update the record
            AContact.Update();
            //find the record
            AContact.ThisContact.Find(PK);
            //test to see that it exists
            Assert.AreEqual(AContact.ThisContact, TestItem);
        }
Beispiel #4
0
    void Update()
    {
        //create an instance of the booking list
        clsContactUsCollection Contacts = new clsContactUsCollection();
        //validate the data on the web form
        //string foreName, string surname, string dateOfBirth, string gender, string contactNumber, string eMail, string flatNo, string houseNo, string postCode
        String Error = Contacts.ThisContact.Valid(txtEmail.Text, txtName.Text, txtMessage.Text);

        //if the data is OK then add it to the object
        if (Error == "")
        {
            //find the record to update
            Contacts.ThisContact.Find(ContactId);
            //get the data entered by the user
            Contacts.ThisContact.Email   = Convert.ToString(txtEmail.Text);
            Contacts.ThisContact.Name    = Convert.ToString(txtName.Text);
            Contacts.ThisContact.Message = Convert.ToString(txtMessage.Text);
            //CList.ThisCustomer.UserName = User.Identity.Name;
            //update the record
            Contacts.Update();
            //all done so redirect back to the main page
            //  Response.Redirect("AdminHomepage.aspx");
            lblError.Text = "update";
        }
        else
        {
            //report an error
            lblError.Text = "There were problems with the data entered " + Error;
        }
    }
Beispiel #5
0
        public void InstanceOK()
        {
            //create a new instance of the class we want to create
            clsContactUsCollection AContact = new clsContactUsCollection();

            //test to see if it exists
            Assert.IsNotNull(AContact);
        }
Beispiel #6
0
        public void FilterbyEmailNoneFound()
        {
            //create an instance of the filtered data
            clsContactUsCollection FilteredContacts = new clsContactUsCollection(" ");

            //apply a blank string (should return all records)
            FilteredContacts.FilterbyEmail("xxx xxx");
            //test to see the two values are the same
            Assert.AreEqual(0, FilteredContacts.Count);
        }
Beispiel #7
0
    void DisplayContact()
    {
        //create an instance of the booking list
        clsContactUsCollection Contacts = new clsContactUsCollection();

        //find the record to update
        Contacts.ThisContact.Find(ContactId);
        //display the data for this record
        txtEmail.Text   = Contacts.ThisContact.Email;
        txtName.Text    = Contacts.ThisContact.Name;
        txtMessage.Text = Contacts.ThisContact.Message;
    }
Beispiel #8
0
        public void FilterbyEmailOK()
        {
            clsContactUs TestItem = new clsContactUs();
            //create an instance of the class we want to create
            clsContactUsCollection AContact = new clsContactUsCollection();
            //create an instance of the filtered data
            clsContactUsCollection FilteredContacts = new clsContactUsCollection("");

            //apply a blank string (should return all records)
            FilteredContacts.FilterbyEmail("");
            //test to see the two values are the same
            Assert.AreEqual(AContact.Count, FilteredContacts.Count);
        }
Beispiel #9
0
    void DisplayContactUs()
    {
        //create an instancew of the Customer Collection
        clsContactUsCollection Contact = new clsContactUsCollection();

        // set the data source to the list of countries in the collection
        lstCont.DataSource = Contact.ContactList;
        // set the name of the primary key
        lstCont.DataValueField = "ContactId";
        // set the data field to display
        lstCont.DataTextField = "AllDetails";
        //bind the data to the list
        lstCont.DataBind();
    }
Beispiel #10
0
    void FilterEmail(string Email)
    {
        //create an instance of the booking collection
        clsContactUsCollection Contact = new clsContactUsCollection();

        Contact.FilterbyEmail(Email);
        //set the data source to the list of bookings in the collection
        lstCont.DataSource = Contact.ContactList;
        //set the name of the primary key
        lstCont.DataValueField = "ContactId";
        //set the data field to display
        lstCont.DataTextField = "Email";
        //bind the data to the list
        lstCont.DataBind();
    }
Beispiel #11
0
        public void ThisContactPropertyOK()
        {
            //create an instance of the class we want to create
            clsContactUsCollection AContact = new clsContactUsCollection();
            //create some test data to assign to the property
            //add an item to the list
            clsContactUs TestContact = new clsContactUs();

            //set its properties
            TestContact.ContactId = 1;
            TestContact.Email     = "*****@*****.**";
            TestContact.Name      = "10";
            TestContact.Message   = "Dinner";
            //assign the data to the property
            AContact.ThisContact = TestContact;//test to see that it exists
            Assert.AreEqual(AContact.ThisContact, TestContact);
        }
Beispiel #12
0
        public void ListAndCountOK()
        {
            //create an instance of the class we want to create
            clsContactUsCollection AContact = new clsContactUsCollection();
            //create some test data to assign to the property
            //in this sceanario it needs to be a lists of objects
            List <clsContactUs> TestList = new List <clsContactUs>();
            //add an item to the list
            //create the item of test data
            clsContactUs TestItem = new clsContactUs();

            //set its properties
            TestItem.Email   = "*****@*****.**";
            TestItem.Name    = "Ayub Osman";
            TestItem.Message = " I Loved the meal. Thanks ! ";
            //add the item to the test list
            TestList.Add(TestItem);
            //assign the data to the property
            AContact.ContactList = TestList;
            //test to see that it exists
            Assert.AreEqual(AContact.Count, TestList.Count);
        }