コード例 #1
0
ファイル: QualityViewer.aspx.cs プロジェクト: kenny348/rtt
    protected void Page_Load(object sender, EventArgs e)
    {
        clsQuality QualityControl = new clsQuality();

        QualityControl = (clsQuality)Session["QualityControl"];
        Response.Write(QualityControl.ProductName);
    }
コード例 #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 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);
        }
コード例 #4
0
        public void StaffIDPropertyOK()
        {
            clsQuality QualityControl = new clsQuality();
            Int32      DataTest       = 1;

            QualityControl.StaffID = DataTest;
            Assert.AreEqual(QualityControl.StaffID, DataTest);
        }
コード例 #5
0
        public void ProductNoPropertyOK()
        {
            clsQuality QualityControl = new clsQuality();
            Int32      DataTest       = 1;

            QualityControl.ProductNo = DataTest;
            Assert.AreEqual(QualityControl.ProductNo, DataTest);
        }
コード例 #6
0
        public void InstanceOK()
        {
            //creates instance of class
            clsQuality QualityControl = new clsQuality();

            //tests to see if it exists
            Assert.IsNotNull(QualityControl);
        }
コード例 #7
0
        public void ProductNamePropertyOK()
        {
            clsQuality QualityControl = new clsQuality();
            String     DataTest       = "Blue";

            QualityControl.ProductName = DataTest;
            Assert.AreEqual(QualityControl.ProductName, DataTest);
        }
コード例 #8
0
        public void ValidMethodOK()
        {
            clsQuality QualityControl = new clsQuality();
            String     Error          = "";

            Error = QualityControl.Valid(ProductName, StaffID, BatchNo, Grade, Date, Defective);
            Assert.AreEqual(Error, "");
        }
コード例 #9
0
        public void FindMethodOK()
        {
            clsQuality QualityControl = new clsQuality();
            Boolean    Found          = false;
            Int32      ProductNo      = 1;

            Found = QualityControl.Find(ProductNo);
            Assert.IsTrue(Found);
        }
コード例 #10
0
        public void ProductNameMaxPlusOne()
        {
            clsQuality QualityControl = new clsQuality();
            String     Error          = "";
            string     ProductName    = "";

            Error = QualityControl.Valid(ProductName, StaffID, BatchNo, Grade, Date, Defective);
            Assert.AreNotEqual(Error, "");
        }
コード例 #11
0
    protected void btnOK_Click(object sender, EventArgs e)
    {
        clsQuality QualityControl = new clsQuality();

        QualityControl.ProductName = txtProductName.Text;
        Session["QualityControl"]  = QualityControl;
        //navigate to viewer page
        Response.Redirect("QualityViewer.aspx");
    }
コード例 #12
0
        public void ProductNameMid()
        {
            clsQuality QualityControl = new clsQuality();
            String     Error          = "";
            string     ProductName    = "";

            ProductName = ProductName.PadRight(10, 'a');
            Error       = QualityControl.Valid(ProductName, StaffID, BatchNo, Grade, Date, Defective);
            Assert.AreNotEqual(Error, "");
        }
コード例 #13
0
        public void GradePropertyOK()
        {
            //create class instance
            clsQuality QualityControl = new clsQuality();
            //create test for property
            Char TestData = 'A';

            //assign data to property
            QualityControl.Grade = TestData;
            //test for if they are equal
            Assert.AreEqual(QualityControl.Grade, TestData);
        }
コード例 #14
0
        public void DatePropertyOK()
        {
            //create instance of class
            clsQuality QualityControl = new clsQuality();
            //create test with datatype DateTime
            DateTime TestData = DateTime.Now.Date;

            //Assign data with property
            QualityControl.Date = TestData;
            //Test to see if they are equal
            Assert.AreEqual(QualityControl.Date, TestData);
        }
コード例 #15
0
        public void DefectivePropertyOK()
        {
            //create instance of class
            clsQuality QualityControl = new clsQuality();
            //create test data
            Boolean TestData = false;

            //assign data to property
            QualityControl.Defective = TestData;
            //test to see if values are the same
            Assert.AreEqual(QualityControl.Defective, TestData);
        }
コード例 #16
0
        public void TestDateFound()
        {
            clsQuality QualityControl = new clsQuality();
            Boolean    Found          = false;
            Boolean    OK             = true;
            Int32      ProductNo      = 1;

            Found = QualityControl.Find(ProductNo);
            if (QualityControl.Date != Convert.ToDateTime("01/01/2021"))
            {
                OK = false;
            }
            Assert.IsTrue(OK);
        }
コード例 #17
0
        public void TestBatchNoFound()
        {
            clsQuality QualityControl = new clsQuality();
            Boolean    Found          = false;
            Boolean    OK             = true;
            Int32      ProductNo      = 1;

            Found = QualityControl.Find(ProductNo);
            if (QualityControl.BatchNo != 1)
            {
                OK = false;
            }
            Assert.IsTrue(OK);
        }
コード例 #18
0
        public void TestDefectiveFound()
        {
            clsQuality QualityControl = new clsQuality();
            Boolean    Found          = false;
            Boolean    OK             = true;
            Int32      ProductNo      = 1;

            Found = QualityControl.Find(ProductNo);
            if (QualityControl.Defective != true)
            {
                OK = false;
            }
            Assert.IsTrue(OK);
        }
コード例 #19
0
        public void TestProductNameFound()
        {
            clsQuality QualityControl = new clsQuality();
            Boolean    Found          = false;
            Boolean    OK             = true;
            Int32      ProductNo      = 1;

            Found = QualityControl.Find(ProductNo);
            if (QualityControl.ProductName != "Blue")
            {
                OK = false;
            }
            Assert.IsTrue(OK);
        }
コード例 #20
0
    protected void btnFind_Click(object sender, EventArgs e)
    {
        clsQuality QualityControl = new clsQuality();
        Int32      ProductNo;
        Boolean    Found = false;

        ProductNo = Convert.ToInt32(txtProductNo.Text);
        Found     = QualityControl.Find(ProductNo);
        if (Found == true)
        {
            txtStaffID.Text     = QualityControl.StaffID.ToString();
            txtBatchNo.Text     = QualityControl.BatchNo.ToString();
            txtGrade.Text       = QualityControl.Grade.ToString();
            txtDate.Text        = QualityControl.Date.ToString();
            txtProductName.Text = QualityControl.ProductName;
        }
    }
コード例 #21
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);
        }
コード例 #22
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);
        }
コード例 #23
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;
        }
    }