Exemplo n.º 1
0
        public void AddMethodOk()
        {
            //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);
            //test to see that the two values are the same
            Assert.AreEqual(AllPhones.ThisPhone, TestItem);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        public void PhoneListOK()
        {
            //create an instance of the class we want to create
            clsPhoneCollection AllPhones = new clsPhoneCollection();
            //create some test data to assign to the property
            //in this case the data needs to be a list of objects
            List <clsPhone> TestList = new List <clsPhone>();
            //add an item to the list
            //create the item of test data
            clsPhone TestItem = new clsPhone();

            //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;
            //add the item to the test list
            TestList.Add(TestItem);
            //assign the data to the property
            AllPhones.PhoneList = TestList;
            //test to see that the two values are the same
            Assert.AreEqual(AllPhones.PhoneList, TestList);
        }
Exemplo n.º 4
0
        public void ListAndCountOk()
        {
            //create an instance of the class we wish to create
            clsPhoneCollection AllPhones = new clsPhoneCollection();
            //create some test data to assign to the property
            //in this case the data needs to be a list of objects
            List <clsPhone> TestList = new List <clsPhone>();
            //add an item to the list
            //create the item test data
            clsPhone TestItem = new clsPhone();

            //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";
            //add the item to the list
            TestList.Add(TestItem);
            //assign the data to the property
            AllPhones.PhoneList = TestList;
            //test to see that the two values are the same
            Assert.AreEqual(AllPhones.Count, TestList.Count);
        }
Exemplo n.º 5
0
        public void AddMethodOK()
        //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);
            //test to see that the two values are the same
            Assert.AreEqual(AllPhones.ThisPhone, TestItem);
        }
Exemplo n.º 6
0
    //this function displays the data for a phone on the web form
    void DisplayBrand(Int32 PhoneNo)
    {
        //create an instance of the phone class
        clsPhone MyPhoneBook = new clsPhone();

        //find the record we want to display
        MyPhoneBook.Find(PhoneNo);
        //display the phone name
        txtPhoneName.Text = MyPhoneBook.PhoneName;
        //display the brand
        txtBrand.Text = MyPhoneBook.Brand;
        //display the screen size
        txtScreenSize.Text = MyPhoneBook.ScreenSize;
        //display the operating system
        txtOperatingSystem.Text = MyPhoneBook.OperatingSystem;
        //display the back camera
        txtBackCamera.Text = MyPhoneBook.BackCamera;
        //display the battery size
        txtBatterySize.Text = MyPhoneBook.BatterySize;
        //display the release data
        txtReleaseDate.Text = MyPhoneBook.ReleaseDate.ToString("dd/MM/yyyy");
        //set the drop down list to display the Company No
        ddlCompany.SelectedValue = Convert.ToString(MyPhoneBook.CompanyNo);
        //display the active state
        chkDiscontinued.Checked = MyPhoneBook.Discontinued;
    }
Exemplo n.º 7
0
        public void InstanceOk()
        {
            //create an instance of the class we want to create
            clsPhone APhone = new clsPhone();

            //test to see if that exists
            Assert.IsNotNull(APhone);
        }
Exemplo n.º 8
0
        public void ValidMethodOk()
        {
            //create an instance of the class we want to create
            clsPhone APhone = new clsPhone();
            //string variable to store any error message
            String Error = "";

            //invoke the method
            Error = APhone.Valid(PhoneMake, PhoneModel, PhoneNo, Price, ScreenSize, CameraQuality);
            //test to see that the result is ok
            Assert.AreEqual(Error, "");
        }
Exemplo n.º 9
0
        public void PhoneIdPropertyOk()
        {
            //create an instance of the class we want to create
            clsPhone APhone = new clsPhone();
            //create some test data to assign to the property
            Int32 TestData = 1;

            //assign the data to the property
            APhone.PhoneId = TestData;
            //test to see if the two values are the same
            Assert.AreEqual(APhone.PhoneId, TestData);
        }
Exemplo n.º 10
0
        public void ValidMethodOK()
        {
            //create an instance of the filtered data
            clsPhone APhone = new clsPhone();
            //string variable to store any error message
            String Error = "";

            //invoke the method
            Error = APhone.Valid(Capacity, Price, Colour, DateAdded, Description, Make, Model);
            //test to see that the result is correct
            Assert.AreEqual(Error, "");
        }
Exemplo n.º 11
0
        public void PhonePricePropertyOk()
        {
            //create an instance of the class we want to create
            clsPhone APhone = new clsPhone();
            //create some test data to assign to the property
            string TestData = "500";

            //assign the data to the property
            APhone.Price = TestData;
            //test to see if the two values are the same
            Assert.AreEqual(APhone.Price, TestData);
        }
Exemplo n.º 12
0
        public void ColourPropertyOK()
        //Colour Property
        {
            //create an instance of the class we want to create
            clsPhone APhone = new clsPhone();
            //create some test data to assign to the property
            String TestData = "red";

            //assign the data to the property
            APhone.Colour = TestData;
            //test to see that the two values are the same
            Assert.AreEqual(APhone.Colour, TestData);
        }
Exemplo n.º 13
0
        public void PricePropertyOK()
        //Price Property
        {
            //create an instance of the class we want to create
            clsPhone APhone = new clsPhone();
            //create some test data to assign to the property
            Int32 TestData = 100;

            //assign the data to the property
            APhone.Price = TestData;
            //test to see that the two values are the same
            Assert.AreEqual(APhone.Price, TestData);
        }
Exemplo n.º 14
0
        public void ActivePropertyOK()
        //Active Property
        {
            //create an instance of the class we want to create
            clsPhone APhone = new clsPhone();
            //create some test data to assign to the property
            Boolean TestData = true;

            //assign the data to the property
            APhone.Active = TestData;
            //test to see that the two values are the same
            Assert.AreEqual(APhone.Active, TestData);
        }
Exemplo n.º 15
0
        public void DescriptionPropertyOK()
        //Description Property
        {
            //create an instance of the class we want to create
            clsPhone APhone = new clsPhone();
            //create some test data to assign to the property
            String TestData = "This is the latest phone.";

            //assign the data to the property
            APhone.Description = TestData;
            //test to see that the two values are the same
            Assert.AreEqual(APhone.Description, TestData);
        }
Exemplo n.º 16
0
        public void DateAddedPropertyOK()
        //DateAdded Property
        {
            //create an instance of the class we want to create
            clsPhone APhone = new clsPhone();
            //create some test data to assign to the property
            DateTime TestData = DateTime.Now.Date;

            //assign the data to the property
            APhone.DateAdded = TestData;
            //test to see that the two values are the same
            Assert.AreEqual(APhone.DateAdded, TestData);
        }
Exemplo n.º 17
0
        private void setTestdata()
        {
            objCustomer = new clsCustomer();
            clsAddress objAddress = new clsAddress();
            clsPhone   objPhone   = new clsPhone();

            objCustomer.strCustomerName = "Shivprasad Koirala";
            objAddress.strAddress1      = "Mumbai";
            objAddress.strAddress2      = "Mulund";
            objPhone.strPhoneNumber     = "99881";
            objAddress.objPhones.Add(objPhone);
            objCustomer.objAddresses.Add(objAddress);
        }
Exemplo n.º 18
0
        public void PhoneMakeMinLessOne()
        {
            //create an instance of the class we want to create
            clsPhone APhone = new clsPhone();
            //string varaible to store any error message
            string Error = "";
            //create some test data to pass to the method
            string PhoneMake = ""; //this should trigger an error

            //invoke the method
            Error = APhone.Valid(PhoneMake, PhoneModel, PhoneNo, Price, ScreenSize, CameraQuality);
            //test to see that the result is correct
            Assert.AreNotEqual(Error, "");
        }
Exemplo n.º 19
0
        public void DateAddedInvalidData()
        {
            //create an instance of the class we want to create
            clsPhone APhone = new clsPhone();
            //string variable to store any error message
            String Error = "";
            //set the DateAdded to a non data value
            string DateAdded = "this is not a date!";

            //invoke the method
            Error = APhone.Valid(Capacity, Price, Colour, DateAdded, Description, Make, Model);
            //test to see that the result is correct
            Assert.AreNotEqual(Error, "");
        }
Exemplo n.º 20
0
        public void DescriptionMid()
        {
            //create an instance of the class we want to create
            clsPhone APhone = new clsPhone();
            //string variable to store any error message
            String Error = "";
            //this should pass
            string Description = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium.";

            //invoke the method
            Error = APhone.Valid(Capacity, Price, Colour, DateAdded, Description, Make, Model);
            //test to see that the result is correct
            Assert.AreEqual(Error, "");
        }
Exemplo n.º 21
0
        public void FindMethodOk()
        {
            //create an instance of the class we want to create
            clsPhone APhone = new clsPhone();
            //boolean variable to store the result of the validation
            Boolean Found = false;
            //create the test data to use with the method
            Int32 PhoneId = 1;

            //invoke the method
            Found = APhone.Find(PhoneId);
            //Test to see that the result is correct
            Assert.IsTrue(Found);
        }
Exemplo n.º 22
0
        public void PriceMid()
        {
            //create an instance of the class we want to create
            clsPhone APhone = new clsPhone();
            //string variable to store any error message
            String Error = "";
            // this should pass
            string Price = "500.00";

            //invoke the method
            Error = APhone.Valid(Capacity, Price, Colour, DateAdded, Description, Make, Model);
            // test to see that the result is correct
            Assert.AreEqual(Error, "");
        }
Exemplo n.º 23
0
        public void FindMethodOK()
        //Find Method
        {
            //create an instance of the filtered data
            clsPhone APhone = new clsPhone();
            //boolean variable to store the result of the validation
            Boolean Found = false;
            //create some test data to use with the method
            Int32 PhoneID = 3;

            //invoke the method
            Found = APhone.Find(PhoneID);
            //test to see that the result is correct
            Assert.IsTrue(Found);
        }
Exemplo n.º 24
0
        public void ModelMaxPlusOne()
        {
            //create an instance of the class we want to create
            clsPhone APhone = new clsPhone();
            //string variable to store any error message
            String Error = "";
            //this should fail
            string Model = "";

            Model = Model.PadRight(11, 'a');
            //invoke the method
            Error = APhone.Valid(Capacity, Price, Colour, DateAdded, Description, Make, Model);
            //test to see that the result is correct
            Assert.AreNotEqual(Error, "");
        }
Exemplo n.º 25
0
        public void PriceMinLessOne()

        {
            //create an instance of the filtered data
            clsPhone APhone = new clsPhone();
            //string variable to store any error message
            String Error = "";
            //create some test data to pass to the method
            string Price = "-0.01"; //this should fail

            //invoke the method
            Error = APhone.Valid(Capacity, Price, Colour, DateAdded, Description, Make, Model);
            //test to see that the result is correct
            Assert.AreNotEqual(Error, "");
        }
Exemplo n.º 26
0
        private void btnAddPhone_Click(object sender, EventArgs e)
        {
            string lcReply = new InputBox(clsPhone.FACTORY_PROMPT).Answer;

            if (!string.IsNullOrEmpty(lcReply)) // not cancelled?

            {
                clsPhone lcPhone = clsPhone.NewPhone(lcReply[0]);
                FrmPhone.DispatchPhoneForm(lcPhone);
                if (lcPhone != null) // valid artwork created?

                {
                    FrmMain.Instance.UpdateDisplay();
                }
            }
        }
Exemplo n.º 27
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //create a new instance of clsAddress
        clsPhone APhone = new clsPhone();

        //get the data from the session object
        APhone = (clsPhone)Session["APhone"];
        //display the phone id number for this entry
        Response.Write(APhone.Model);
        Response.Write(APhone.Make);
        Response.Write(APhone.Capacity);
        Response.Write(APhone.Price);
        Response.Write(APhone.Colour);
        Response.Write(APhone.DateAdded);
        Response.Write(APhone.StockStatus);
    }
Exemplo n.º 28
0
        public void PhoneCameraQualityMaxPlusOne()
        {
            //create an instance of the class we want to create
            clsPhone APhone = new clsPhone();
            //boolean variable to store the result of the validation
            //Boolean OK = false;
            string Error = "";
            //create some test data to pass to the method
            string CameraQuality = "aaaaaa"; //this should fail

            //invoke the method
            //OK = APhone.Valid(PhoneMake, PhoneModel, PhoneNo, Price, ScreenSize, CameraQuality);
            Error = APhone.Valid(PhoneMake, PhoneModel, PhoneNo, Price, ScreenSize, CameraQuality);
            //test to see that the result is correct
            //Assert.IsTrue(OK);
            Assert.AreNotEqual(Error, "");
        }
Exemplo n.º 29
0
        public void DateAddedMin()
        {
            //create an instance of the class we want to create
            clsPhone APhone = new clsPhone();
            //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 DateAdded = TestDate.ToString();

            //invoke the method
            Error = APhone.Valid(Capacity, Price, Colour, DateAdded, Description, Make, Model);
            //test to see that the result is correct
            Assert.AreEqual(Error, "");
        }
Exemplo n.º 30
0
        public void ThisPhonePropertyOk()
        {
            //create an instance of the class we want ot create
            clsPhoneCollection AllPhones = new clsPhoneCollection();
            //create some test data to assign to the property
            clsPhone TestPhone = new clsPhone();

            //set the properties to the test object
            TestPhone.PhoneId       = 1;
            TestPhone.Make          = "Apple";
            TestPhone.Model         = "IPhone X";
            TestPhone.PhoneNo       = "07749493975";
            TestPhone.Price         = "500";
            TestPhone.ScreenSize    = "7.2";
            TestPhone.CameraQuality = "FHD";
            //assign the data to the property
            AllPhones.ThisPhone = TestPhone;
            //test to see that the two values are the same
            Assert.AreEqual(AllPhones.ThisPhone, TestPhone);
        }