コード例 #1
0
        public void UpdateMethodOK()
        {
            clsQualityCollection AllProducts = new clsQualityCollection();
            clsQuality           TestItem    = new clsQuality();
            Int32 PrimaryKey = 1;

            TestItem.Defective      = true;
            TestItem.ProductName    = "Blue";
            TestItem.StaffID        = 1;
            TestItem.BatchNo        = 1;
            TestItem.Grade          = 'A';
            TestItem.Date           = DateTime.Now.Date;
            AllProducts.ThisProduct = TestItem;
            PrimaryKey         = AllProducts.Add();
            TestItem.ProductNo = PrimaryKey;
            //modify test data
            TestItem.ProductName    = "Red";
            TestItem.StaffID        = 2;
            TestItem.BatchNo        = 2;
            TestItem.Date           = DateTime.Now.Date;
            TestItem.Grade          = 'C';
            TestItem.Defective      = false;
            AllProducts.ThisProduct = TestItem;
            AllProducts.Update();
            AllProducts.ThisProduct.Find(PrimaryKey);
            Assert.AreEqual(AllProducts.ThisProduct, TestItem);
        }
コード例 #2
0
        public void ListAndCountOK()
        {
            clsQualityCollection AllProducts = new clsQualityCollection();
            //create test data to assign the property
            //in this case the data needs to be a list of objects
            List <clsQuality> TestList = new List <clsQuality>();
            //add item to list
            //create item of test data
            clsQuality TestItem = new clsQuality();

            //set its properties
            TestItem.Defective   = false;
            TestItem.ProductNo   = 1;
            TestItem.StaffID     = 1;
            TestItem.BatchNo     = 1;
            TestItem.Grade       = 'A';
            TestItem.Date        = DateTime.Now.Date;
            TestItem.ProductName = "Blue";
            //add item to the test list
            TestList.Add(TestItem);
            //Assign the data to the property
            AllProducts.ProductList = TestList;
            //test to see that the two values are the same
            Assert.AreEqual(AllProducts.Count, TestList.Count);
        }
コード例 #3
0
        public void CountPropertyOK()
        {
            clsQualityCollection AllProducts = new clsQualityCollection();
            Int32 SomeCount = 0;

            AllProducts.Count = SomeCount;
            Assert.AreEqual(AllProducts.Count, SomeCount);
        }
コード例 #4
0
        public void InstanceOK()
        {
            //create instance of class
            clsQualityCollection AllProducts = new clsQualityCollection();

            //test to see if it exists
            Assert.IsNotNull(AllProducts);
        }
コード例 #5
0
    void DisplayProducts()
    {
        //create instance of product collection
        clsQualityCollection AllProducts = new clsQualityCollection();

        //set data source to the list of batches in the collection
        lstProductList.DataSource     = AllProducts.ProductList;
        lstProductList.DataValueField = "ProductNo";
        lstProductList.DataTextField  = "ProductName";
        lstProductList.DataBind();
    }
コード例 #6
0
        public void ThisProductPropertyOK()
        {
            clsQualityCollection AllProducts = new clsQualityCollection();
            //create test data to assign the property
            //create item of test data
            clsQuality TestProduct = new clsQuality();

            //set its properties
            TestProduct.Defective   = false;
            TestProduct.ProductNo   = 1;
            TestProduct.StaffID     = 1;
            TestProduct.BatchNo     = 1;
            TestProduct.Grade       = 'A';
            TestProduct.Date        = DateTime.Now.Date;
            TestProduct.ProductName = "Blue";
            //Assign the data to the property
            AllProducts.ThisProduct = TestProduct;
            //test to see that the two values are the same
            Assert.AreEqual(AllProducts.ThisProduct, TestProduct);
        }
コード例 #7
0
        public void DeleteMethodOK()
        {
            clsQualityCollection AllProducts = new clsQualityCollection();
            clsQuality           TestItem    = new clsQuality();
            Int32 PrimaryKey = 0;

            TestItem.Defective      = true;
            TestItem.ProductNo      = 1;
            TestItem.ProductName    = "Blue";
            TestItem.StaffID        = 1;
            TestItem.BatchNo        = 1;
            TestItem.Date           = DateTime.Now.Date;
            TestItem.Grade          = 'A';
            AllProducts.ThisProduct = TestItem;
            PrimaryKey         = AllProducts.Add();
            TestItem.ProductNo = PrimaryKey;
            AllProducts.ThisProduct.Find(PrimaryKey);
            AllProducts.Delete();
            Boolean Found = AllProducts.ThisProduct.Find(PrimaryKey);

            Assert.IsFalse(Found);
        }
コード例 #8
0
    protected void btnOK_Click(object sender, EventArgs e)
    {
        clsQuality QualityControl = new clsQuality();
        string     ProductName    = txtProductName.Text;
        string     ProductNo      = txtProductNo.Text;
        //capture the StaffID
        string StaffID = txtStaffID.Text;
        //capture the Batch number
        string BatchNo = txtBatchNo.Text;
        string Grade   = txtGrade.Text;
        string Date    = txtDate.Text;
        // varlable to store any error messages
        string Error = "";

        //validate the data
        Error = QualityControl.Valid(ProductNo, ProductName, StaffID, BatchNo, Grade, Date);
        if (Error == "")
        {
            QualityControl.ProductName = txtProductName.Text;
            QualityControl.StaffID     = Convert.ToInt32(txtStaffID.Text);
            QualityControl.BatchNo     = Convert.ToInt32(txtBatchNo.Text);
            QualityControl.Grade       = Convert.ToChar(txtGrade.Text);
            QualityControl.Date        = Convert.ToDateTime(txtDate.Text);
            QualityControl.Defective   = chkDefective.Checked;
            QualityControl.ProductName = txtProductName.Text;
            clsQualityCollection ProductList = new clsQualityCollection();
            ProductList.ThisProduct = QualityControl;
            ProductList.Add();

            //navigate to viewer page
            Response.Redirect("QualityList.aspx");
        }
        else
        {
            lblError.Text = Error;
        }
    }
コード例 #9
0
        public void TwoRecordsPresent()
        {
            clsQualityCollection AllProducts = new clsQualityCollection();

            Assert.AreEqual(AllProducts.Count, 2);
        }