public void DeleteMethodOk()
        {
            //create an instance of the class we want to create
            clsPhoneCollection AllPhones = new clsPhoneCollection();
            //create the item of test data
            clsPhone TestItem = new clsPhone();
            //var to store the primary key
            Int32 PrimaryKey = 0;

            //set its properties
            TestItem.PhoneId       = 1;
            TestItem.Make          = "Apple";
            TestItem.Model         = "Iphone X";
            TestItem.PhoneNo       = "07749493975";
            TestItem.Price         = "500";
            TestItem.ScreenSize    = "7";
            TestItem.CameraQuality = "HD";
            //set ThisPhone to the test data
            AllPhones.ThisPhone = TestItem;
            //add the record
            PrimaryKey = AllPhones.Add();
            //set the primary key of the test data
            TestItem.PhoneId = PrimaryKey;
            //find the record
            AllPhones.ThisPhone.Find(PrimaryKey);
            //delete the record
            AllPhones.Delete();
            //now find the record
            Boolean Found = AllPhones.ThisPhone.Find(PrimaryKey);

            //test to see that the record was not found
            Assert.IsFalse(Found);
        }
        void DeleteSelectedPhone()
        {
            //create an instance of the phone book
            clsPhoneCollection PhoneBook = new clsPhoneCollection();

            //find the record to delete
            PhoneBook.ThisPhone.Find(PhoneId);
            //delete the record
            PhoneBook.Delete();
        }
Beispiel #3
0
    protected void btnYes_Click(object sender, EventArgs e)
    {
        //this function handles the click even of the yes button

        //create an instance of the class clsPhoneCollection called This phone
        clsPhoneCollection MyPhoneBook = new clsPhoneCollection();
        //declare a boolean variable for Found
        Boolean Found;

        //try and find the record to delete
        Found = MyPhoneBook.ThisPhone.Find(PhoneNo);
        //if the record is found
        if (Found)
        {
            //invoke the delete method
            MyPhoneBook.Delete();
        }
        Response.Redirect("Default.aspx");
    }
Beispiel #4
0
        public void DeleteMethodOK()
        //Add Method
        {
            //create an instance of the class we want to create
            clsPhoneCollection AllPhones = new clsPhoneCollection();
            //create the item of test data
            clsPhone TestItem = new clsPhone();
            //var to store the primary key
            Int32 PrimaryKey = 0;

            //set its properties
            TestItem.Active      = true;
            TestItem.PhoneID     = 1;
            TestItem.Capacity    = 128;
            TestItem.Price       = 100;
            TestItem.Colour      = "red";
            TestItem.DateAdded   = DateTime.Now.Date;
            TestItem.Description = "This is the latest phone.";
            TestItem.Make        = "Apple";
            TestItem.Model       = "C3500";
            TestItem.StockStatus = true;
            //set ThisPhone to the test data
            AllPhones.ThisPhone = TestItem;
            //add the record
            PrimaryKey = AllPhones.Add();
            //set the primary key of the test data
            TestItem.PhoneID = PrimaryKey;
            //find the record
            AllPhones.ThisPhone.Find(PrimaryKey);
            //delete the record
            AllPhones.Delete();
            //now find the record
            Boolean Found = AllPhones.ThisPhone.Find(PrimaryKey);

            //test to see that the two values are the same
            Assert.AreEqual(AllPhones.ThisPhone, TestItem);
        }