Ejemplo n.º 1
0
 public void StockListOK()
 {
     //create an instance of the class
     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<clsStockItem> TestList = new List<clsStockItem>();
     //add an item to the list
     //create the item of test data
     clsStockItem TestItem = new clsStockItem();
     //set its properties
     //TestItem.Active = true;
     TestItem.StockNo = 12;
     TestItem.StockName = "Windows";
     TestItem.ItemPrice = 38;
     TestItem.StockItemDescription = "Windows 12, completely rubbish";
     TestItem.SupplierName = "Microsoft";
     TestItem.StockLevel =34;
     //add the item to the test list
     TestList.Add(TestItem);
     //assign the data to the property
     AllStock.StockList = TestList;
     //test to see that the tow calues are the sam
     Assert.AreEqual(AllStock.StockList, TestList);
 }
Ejemplo n.º 2
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<clsStockItem> TestList = new List<clsStockItem>();
         //add an item to the list
         //create the item of test data
     clsStockItem TestItem = new clsStockItem();
         //set its properties
     //TestItem.Active = true;
     TestItem.StockNo = 1;
     TestItem.StockItemDescription = "Completely rubbish software";
     TestItem.StockLevel = 12;
     TestItem.StockName = "Microsoft Windows 10";
     TestItem.ItemPrice = 300;
         //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 value are the same
     Assert.AreEqual(AllStock.Count, TestList.Count);
         
 }
Ejemplo n.º 3
0
    //function for adding new records
    void Add()
    {
        //create an instance of the Stockrecords
        clsStockCollection StockItems = new clsStockCollection();
        //validate the data on the web form
        Boolean OK = StockItems.ThisStockItem.Valid(txtStockName.Text, txtItemPrice.Text, txtItemDescription.Text, txtSupplierName.Text, txtStockLevel.Text);
        //if the data is OK then add it to the onject
        if (OK == true)
        {

            //get the data entered by the user

            StockItems.ThisStockItem.StockName = txtStockName.Text;
            StockItems.ThisStockItem.ItemPrice =Convert.ToDecimal( txtItemPrice.Text);
            StockItems.ThisStockItem.StockItemDescription = txtItemDescription.Text;
            StockItems.ThisStockItem.StockLevel =Convert.ToInt32( txtStockLevel.Text);
            StockItems.ThisStockItem.SupplierName = txtSupplierName.Text;
            //add the record
            StockItems.Add();
        }
        else
        {
            //report an error
            lblError.Text = "There were problems with the data entered";
        }

    }
Ejemplo n.º 4
0
 void DisplayProducts()
 {
     ClassLibrary1.clsStockCollection Products = new ClassLibrary1.clsStockCollection();
     lstProductList.DataSource     = Products.ProductList;
     lstProductList.DataValueField = "ProductId";
     lstProductList.DataTextField  = "StyleName";
     lstProductList.DataBind();
 }
Ejemplo n.º 5
0
        public void InstanceOK()
        {

            //create an instance of the class we want to create
            clsStockCollection AllStock=new clsStockCollection();
            //test to see that it exists
            Assert.IsNotNull(AllStock);
        }
Ejemplo n.º 6
0
 public void CountPropertyOK()
 {
     //create an instance of the class we want to create
     clsStockCollection AllStock = new clsStockCollection();
     //create some test data to assign to the property
     Int32 SomeCount = 3;
     //assign the data to the property
     AllStock.Count = SomeCount;
     //test to see that the two values are the same
     Assert.AreEqual(AllStock.Count, SomeCount);
 }
Ejemplo n.º 7
0
        public void ThisStockItemPropertyOK()
        {

            //create an instance of the class we want to create
            clsStockCollection AllStock = new clsStockCollection();
            //create some test data to assign to the property
            clsStockItem TestStockItem = new clsStockItem();
            //set the porpertoies of the test object
            //TestStockItem.Active = true;
            TestStockItem.StockNo = 1;
            
            TestStockItem.StockItemDescription = "Completely rubbish software";
            TestStockItem.StockLevel = 12;
            TestStockItem.StockName = "Microsoft Windows 10";
            TestStockItem.ItemPrice = 300;
            //assign the data to the property
            AllStock.ThisStockItem = TestStockItem;
            //test to see that the tow values are the same
            Assert.AreEqual(AllStock.ThisStockItem, TestStockItem);
        }
Ejemplo n.º 8
0
        public void AddMethodOK()
        {

            // create an instance of the class we want to create
            clsStockCollection AllStock = new clsStockCollection();
            //create the item of test data
            clsStockItem TestItem = new clsStockItem();
            //var to store the primary key
            Int32 PrimaryKey = 0;
            //set it's properties
            TestItem.StockNo = 1;
            //TestItem.ItemPrice = "2.50";
            TestItem.StockName = "Microsoft windows";
            TestItem.StockItemDescription = "Something really useful";
            TestItem.StockLevel = 5;
            TestItem.SupplierName = "Someone really wealthy";
            //set ThisStockItem to the test data
            AllStock.ThisStockItem = TestItem;
            //add the record
            PrimaryKey = AllStock.Add();
            //set the primary key of the test data
            TestItem.StockNo = PrimaryKey;
            //find the record
            AllStock.ThisStockItem.Find(PrimaryKey);
            //test to see that the two values are the same
            Assert.AreEqual(AllStock.ThisStockItem, TestItem);

        }