示例#1
0
    protected void ButtonOK_Click2(object sender, EventArgs e)
    {
        //create a new instance of ClsStock
        ClsStock AnStock = new ClsStock();
        //capture the product description
        string ProductDescript = txtProductDescript.Text;
        //capture the price of the product
        string Cost = txtCost.Text;
        //capture the date the product was added
        string DateAdded = txtDateAdded.Text;
        //capture the stock number
        string StockNo = txtStockNo.Text;
        //variable to store any error messages
        string Error = "";

        //validate the data
        Error = AnStock.Valid(ProductDescript, Cost, StockNo, DateAdded);
        if (Error == "")
        {
            //capture the product ID
            AnStock.StockNo = StockNo;
            //capture the produt description
            AnStock.ProductDescript = ProductDescript;
            //capture the cost
            AnStock.Cost = Cost;
            //capture the date the stock was added
            AnStock.DateAdded = Convert.ToDateTime(DateAdded);
            //capture the stock quantity
            AnStock.StockNo = StockNo;
            //capture the in stock
            AnStock.InStck = chkInStck.Checked;
            //create a new instance of the stock collection
            clsStockCollection StockList = new clsStockCollection();

            if (ProductNo == -1)
            {
                //set the ThisStock property
                StockList.ThisStock = AnStock;
                //add the new record
                StockList.Add();
            }
            //otherwise it must be an updte
            else
            {
                //find the record to update
                StockList.ThisStock.Find(ProductNo);
                //set the ThisStock property
                StockList.ThisStock = AnStock;
                //update the record
                StockList.Update();
            }
            //redirect to the viewer page
            Response.Write("StockNoViewer.aspx");
        }
        else
        {
            //display the error message
            lblError.Text = Error;
        }
    }
        public void AddMethodStockOK()
        {
            ClsStockCollection AllAddresses = new ClsStockCollection();

            ClsStock TestItem = new ClsStock();

            Int32 PrimaryKey = 0;

            TestItem.ShoeID        = 1;
            TestItem.Name          = "AirForce";
            TestItem.Release       = DateTime.Now.Date;
            TestItem.QuantityStock = 1;
            TestItem.PriceStock    = 1;
            TestItem.Size          = 1;

            AllAddresses.ThisStock = TestItem;

            PrimaryKey = AllAddresses.Add();

            TestItem.ShoeID = PrimaryKey;

            AllAddresses.ThisStock.Find(PrimaryKey);

            Assert.AreEqual(AllAddresses.ThisAddressList, TestItem);
        }
示例#3
0
        public void ListAndCountOK()
        {
            //create an instance of the class we want to create
            clsStockCollection AllStock = new clsStockCollection();
            //create some test data to assign to the property
            //in this case the data needs to be a list of objects
            List <ClsStock> TestList = new List <ClsStock>();
            //add an item to the list
            //create the item of test data
            ClsStock TestItem = new ClsStock();

            //set its properties
            TestItem.ProductNo       = 5;
            TestItem.ProductDescript = "Liverpool Shirt";
            TestItem.Cost            = 69;
            TestItem.DateAdded       = DateTime.Now.Date;
            TestItem.StockNo         = 50;
            TestItem.InStck          = true;
            //add the item to the test list
            TestList.Add(TestItem);
            //assign the data to the property
            AllStock.StockList = TestList;
            //test to see that the two values are the same
            Assert.AreEqual(AllStock.Count, TestList.Count);
        }
示例#4
0
        public void ReleaseExtMaz()
        {
            try
            {
                ClsStock Stock = new ClsStock();

                String Error = "";

                DateTime TestDate;

                TestDate = DateTime.Now.Date;

                TestDate = TestDate.AddYears(100);

                string DateAdded = TestDate.ToString();

                Error = Stock.Valid(Name, Release, Quantity, Price, Size);

                Assert.AreEqual(Error, "");
            }

            catch (Exception)
            {
            }
        }
示例#5
0
        public void TestReleaseFound()
        {
            try
            {
                ClsStock Stock = new ClsStock();

                Boolean Found = false;

                Boolean OK = true;

                Int32 ShoeID = 2;

                Found = Stock.Find(ShoeID);

                if (Stock.Release != Convert.ToDateTime("22/02/2020"))
                {
                    OK = false;
                }

                Assert.IsTrue(OK);
            }

            catch (Exception ex)
            { }
        }
示例#6
0
        public void TestSizeFound()
        {
            try
            {
                ClsStock Stock = new ClsStock();

                Boolean Found = false;

                Boolean OK = true;

                Int32 ShoeID = 2;

                Found = Stock.Find(ShoeID);

                if (Stock.Size != 5)
                {
                    OK = false;
                }

                Assert.IsTrue(OK);
            }

            catch (Exception ex)
            { }
        }
示例#7
0
        public void AddMethodOK()
        {
            //create an instance of the class we want to create
            clsStockCollection AllStock = new clsStockCollection();
            //create the item of test data
            ClsStock TestItem = new ClsStock();
            //var to store the primary key
            Int32 PrimaryKey = 0;

            //set its properties
            TestItem.InStck          = true;
            TestItem.ProductNo       = 1;
            TestItem.ProductDescript = "Liverpool Shirt";
            TestItem.Cost            = 59;
            TestItem.StockNo         = 50;
            TestItem.DateAdded       = DateTime.Now.Date;
            //set ThisStock to the test data
            AllStock.ThisStock = TestItem;
            //add the record
            PrimaryKey = AllStock.Add();
            //set the primary key of the test data
            TestItem.ProductNo = PrimaryKey;
            //find the record
            AllStock.ThisStock.Find(PrimaryKey);
            //test to see that the two values are the same
            Assert.AreEqual(AllStock.ThisStock, TestItem);
        }
示例#8
0
        public void DeleteMethodOK()
        {
            //create an instance of the class we want to create
            clsStockCollection AllStock = new clsStockCollection();
            //create the item of test data
            ClsStock TestItem = new ClsStock();
            //var to store the primary key
            Int32 PrimaryKey = 0;

            //set its properties
            TestItem.InStck          = true;
            TestItem.ProductNo       = 1;
            TestItem.ProductDescript = "Liverpool Shirt";
            TestItem.Cost            = 59;
            TestItem.StockNo         = 50;
            TestItem.DateAdded       = DateTime.Now.Date;
            //set ThisStock to the test data
            AllStock.ThisStock = TestItem;
            //add the record
            PrimaryKey = AllStock.Add();
            //set the primary key of the test data
            TestItem.StockNo = PrimaryKey;
            //find the record
            AllStock.ThisStock.Find(PrimaryKey);
            //delete the record
            AllStock.Delete();
            //now find the record
            Boolean Found = AllStock.ThisStock.Find(PrimaryKey);

            //test to see that the record was not found
            Assert.IsFalse(Found);
        }
示例#9
0
        public void InstanceOK()
        {
            //create an instance of the class we want to create
            ClsStock AnStock = new ClsStock();

            //test to see that it exists
            Assert.IsNotNull(AnStock);
        }
示例#10
0
        public void ReleaseOK()
        {
            ClsStock Stock = new ClsStock();

            DateTime TestData = DateTime.Now.Date;

            Stock.Release = TestData;

            Assert.AreEqual(Stock.Release, TestData);
        }
示例#11
0
        public void NameOK1()
        {
            ClsStock Stock = new ClsStock();

            var TestData = "Nike";

            Stock.Name = TestData;

            Assert.AreEqual(Stock.Name, TestData);
        }
示例#12
0
        public void ShoeIdOK()
        {
            ClsStock Stock = new ClsStock();

            int TestData = 1;

            Stock.ShoeID = TestData;

            Assert.AreEqual(Stock.ShoeID, TestData);
        }
示例#13
0
        public void QuantityStockOK()
        {
            ClsStock Stock = new ClsStock();

            int TestData = 4;

            Stock.QuantityStock = TestData;

            Assert.AreEqual(Stock.QuantityStock, TestData);
        }
示例#14
0
        public void PriceStockOK()
        {
            ClsStock Stock = new ClsStock();

            int TestData = 4;

            Stock.PriceStock = TestData;

            Assert.AreEqual(Stock.PriceStock, TestData);
        }
示例#15
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //create a new instance of ClsStock
        ClsStock AnStock = new ClsStock();

        //get the data from the session object
        AnStock = (ClsStock)Session["AnStock"];
        //display the stock number
        Response.Write(AnStock.ProductDescript);
    }
示例#16
0
        public void SizekOK()
        {
            ClsStock Stock = new ClsStock();

            int TestData = 10;

            Stock.Size = TestData;

            Assert.AreEqual(Stock.Size, TestData);
        }
示例#17
0
        public void InStockOK()
        {
            //create an instance of the class we want to create
            ClsStock AnStock = new ClsStock();
            //create some test data to assign to the property
            Boolean TestData = true;

            //assign the data to the property
            AnStock.InStck = TestData;
            //test to see that the two values are the same
            Assert.AreEqual(AnStock.InStck, TestData);
        }
示例#18
0
        public void StockDateOK()
        {
            //create an instance of the class we want to create
            ClsStock AnStock = new ClsStock();
            //create some test data to assign to the property
            DateTime TestData = DateTime.Now.Date;

            //assign the data to the property
            AnStock.DateAdded = TestData;
            //test to see that the two values are the same
            Assert.AreEqual(AnStock.DateAdded, TestData);
        }
示例#19
0
        public void StockQuantityOK()
        {
            //create an instance of the class we want to create
            ClsStock AnStock = new ClsStock();
            //create some test data to assign to the property
            Int32 TestData = 50;

            //assign the data to the property
            AnStock.StockNo = TestData;
            //test to see that the two values are the same
            Assert.AreEqual(AnStock.StockNo, TestData);
        }
示例#20
0
        public void ProductDescriptionOK()
        {
            //create an instance of the class we want to create
            ClsStock AnStock = new ClsStock();
            //create some test data to assign to the property
            string TestData = "Liverpool Shirt";

            //assign the data to the property
            AnStock.ProductDescript = TestData;
            //test to see that the two values are the same
            Assert.AreEqual(AnStock.ProductDescript, TestData);
        }
示例#21
0
        public void ValidMethodOK()
        {
            //create an instance of the class we want to create
            ClsStock AnStock = new ClsStock();
            //string variable to store any error message
            String Error = "";

            //invoke the method
            Error = AnStock.Valid(ProductDescript, Cost, StockNo, DateAdded);
            //test to see that the result is correct
            Assert.AreEqual(Error, "");
        }
示例#22
0
        public void fillcprice()
        {
            ClsStock objstock = new ClsStock();
            Stock    obj      = new Stock();

            //obj = objstock.
            if (ddlprod != null)
            {
                txtcprice.Text = Convert.ToInt32(obj.Price).ToString();
                //   txtcstock.Text = Convert.ToInt32(pd.ProductId).ToString();
            }
        }
示例#23
0
        public void fillcstock(int id)
        {
            ClsStock objstock = new ClsStock();
            Stock    obj      = new Stock();

            //obj = objstock.
            if (ddlprod != null)
            {
                // txtcstock.Text =
                txtcstock.Text = Convert.ToInt32(obj.ProductId).ToString();
            }
        }
示例#24
0
 public void ValidMethodStockOK()
 {
     try
     {
         ClsStock Stock = new ClsStock();
         String   Error = "";
         Error = Stock.Valid(Name, Release, Quantity, Price, Size);
         Assert.AreEqual(Error, "");
     }
     catch (Exception)
     {
     }
 }
示例#25
0
        public void DateAddedInvalidData()
        {
            //create an instance of the class we want to create
            ClsStock AnStock = new ClsStock();
            //string variable to store any error message
            String Error = "";
            //set the DateAdded to a non date value
            string DateAdded = "this is not a date";

            //invoke the method
            Error = AnStock.Valid(ProductDescript, Cost, StockNo, DateAdded);
            //test to see that the result is correct
            Assert.AreNotEqual(Error, "");
        }
示例#26
0
        public void ProductDescriptMid()
        {
            //create an instance of the class we want to create
            ClsStock AnStock = new ClsStock();
            //string variable to store any error message
            String Error = "";
            //create some test data to pass to the method
            string ProductDescript = "aaaa"; //this should be ok

            //invoke the method
            Error = AnStock.Valid(ProductDescript, Cost, StockNo, DateAdded);
            //test to see that the result is correct
            Assert.AreEqual(Error, "");
        }
示例#27
0
        public void FindMethodOK()
        {
            //create
            ClsStock AnStock = new ClsStock();
            //boolean
            Boolean Found = false;
            //create
            Int32 StockNo = 1;

            //invoke
            Found = AnStock.Find(StockNo);
            //test
            Assert.IsTrue(Found);
        }
示例#28
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            ClsStock Stock = new ClsStock();

            Stock = (ClsStock)Session["Stock"];

            if (Stock != null)
            {
                Response.Write(Stock.ShoeID);
            }
        }
    }
示例#29
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        //create a new instance of ClsStock
        ClsStock AnStock = new ClsStock
        {
            //capture the product ID
            ProductNo = txtProductNo.Test
        };

        //store the stock number in the session object
        Session["AnStock"] = AnStock;
        //redirect to the viewer page
        Response.Redirect("StockNumberViewer.aspx");
    }
示例#30
0
        public void FindMethodStockOK()
        {
            try
            {
                ClsStock Stock = new ClsStock();

                Boolean Found = false;

                Int32 ShoeID = 2;

                Found = Stock.Find(ShoeID);

                Assert.IsTrue(Found);
            }
            catch (Exception ex)
            { }
        }