Esempio n. 1
0
 public void ProductInstanceOK()
 {
     //create an instance of the product class
     clsProduct TestProduct = new clsProduct();
     //test to see that exists
     Assert.IsNotNull(TestProduct);
 }
Esempio n. 2
0
     public clsProductCollection()
 {
     //var for the index
     Int32 Index = 0;
     //var to store the record count
     Int32 RecordCount = 0;
     //object for the data connection
     clsDataConnection DB = new clsDataConnection();
     //execute the stored procedure
     DB.Execute("sproc_tblProduct_SelectAll");
     //get the count of records
     RecordCount = DB.Count;
     //while there are records to proccess
     while (Index < RecordCount)
     {
         //create a blank customer
         clsProduct AProduct = new clsProduct();
     //    //read in the fields from the current record               
         AProduct.ProductNo = Convert.ToInt32(DB.DataTable.Rows[Index]["ProductNo"]);
         AProduct.ProductName = Convert.ToString(DB.DataTable.Rows[Index]["ProductName"]);
         AProduct.ProductType = Convert.ToString(DB.DataTable.Rows[Index]["ProductType"]);
         AProduct.ProductDescription = Convert.ToString(DB.DataTable.Rows[Index]["ProductDescription"]);
         AProduct.ProductPrice = Convert.ToDecimal(DB.DataTable.Rows[Index]["ProductPrice"]);
         AProduct.ProductManufacturer = Convert.ToString(DB.DataTable.Rows[Index]["ProductManufacturer"]);
         AProduct.ProductsInStock = Convert.ToInt32(DB.DataTable.Rows[Index]["ProductsInStock"]);
     //    //add the record to the private data member
         productList.Add(AProduct);
     //    //point at the next record
         Index++;
     }
 }
Esempio n. 3
0
 public void ProductListOK()
 {
     //create an instance of the class we want to create
     clsProductCollection AllProducts = new clsProductCollection();
     //create some test data to assign to the property
     //in this case the data needs to be a list of objects
     List<clsProduct> TestList = new List<clsProduct>();
     //add an item to the list
     //create the item of the test data
     clsProduct TestItem = new clsProduct();
     //set its properties
     TestItem.ProductNo = 1;
     TestItem.ProductName = "AJazz Keyboard";
     TestItem.ProductType = "Keyboard";
     TestItem.ProductDescription = "Mechanical Keyboard";
     TestItem.ProductPrice = 6;
     TestItem.ProductManufacturer = "AJazz";
     TestItem.ProductsInStock = 8;
     //add the 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.ProductList, TestList);
 }
Esempio n. 4
0
 public void ProductOK()
 {
     clsProduct TestProduct = new clsProduct();
     string TestData = "Keyboards";
     TestProduct.Product = TestData;
     Assert.AreEqual(TestProduct.Product, TestData);
 }
Esempio n. 5
0
 public void ProductPrice()
 {
     //create an instance of the class we want to create
     clsProduct AProduct = new clsProduct();
     //Create test data 
     decimal AProductPrice = 6;
     //assign the data to the property
     AProduct.ProductPrice = AProductPrice;
     //two values are the same
     Assert.AreEqual(AProduct.ProductPrice, AProductPrice);
 }
Esempio n. 6
0
 public void ProductDescription()
 {
     //create an instance of the class we want to create
     clsProduct AProduct = new clsProduct();
     //Create test data 
     string AProductDescription = "Mechanical Keyboard";
     //assign the data to the property
     AProduct.ProductDescription = AProductDescription;
     //two values are the same
     Assert.AreEqual(AProduct.ProductDescription, AProductDescription);
 }
Esempio n. 7
0
 public void ProductType()
 {
     //create an instance of the class we want to create
     clsProduct AProduct = new clsProduct();
     //Create some test data to assign to the property
     string AProductType = "Keyboard";
     //assign the data to the property
     AProduct.ProductType = AProductType;
     //test to see that the two values are the same
     Assert.AreEqual(AProduct.ProductType, AProductType);
 }
Esempio n. 8
0
 public void ProductNo()
 {
     //create an instance of the class we want to create
     clsProduct AProduct = new clsProduct();
     //Create some test data to assign to the property
     int ProductNumber = 2;
     //assign the data to the property
     AProduct.ProductNo = ProductNumber;
     //test to see that the two values are the same
     Assert.AreEqual(AProduct.ProductNo, ProductNumber);
 }
Esempio n. 9
0
 public void ThisProductPropertyOK()
 {
     //create an instance of the class that we want to create 
     clsProductCollection AllProducts = new clsProductCollection();
     //create sometest data to assign to the property
     clsProduct TestProduct = new clsProduct();
     //set the properties of the test object
     TestProduct.ProductNo = 1;
     TestProduct.ProductName = "AJazz Keyboard";
     TestProduct.ProductType = "Keyboard";
     TestProduct.ProductDescription = "Mechanical Keyboard";
     TestProduct.ProductPrice = 6;
     TestProduct.ProductManufacturer = "AJazz";
     TestProduct.ProductsInStock = 8;
     //assign the data to the property
     AllProducts.ThisProduct = TestProduct;
     //test to see that the two values are the same
     Assert.AreEqual(AllProducts.ThisProduct, TestProduct);
 }
Esempio n. 10
0
 public void ProductManufacturerMinLessOne()
 {
     //create an instance of the class we want to create
     clsProduct AProduct = new clsProduct();
     //Boolean variable to store the result of the validation
     Boolean OK = false;
     //create some test data to use with the method
     String ProductName = "AJazz";
     String ProductType = "Keyboard";
     String ProductDescription = "Mechanical Keyboard";
     Decimal ProductPrice = 6;
     String ProductManufacturer = "";
     Int32 ProductsInStock = 8;
     //invoke the mothod
     OK = AProduct.Valid(ProductName, ProductType, ProductDescription, ProductPrice, ProductManufacturer,
                          ProductsInStock);
     //test to see if the result is correct
     Assert.IsFalse(OK);
 }
Esempio n. 11
0
 public void ProductManufacturer()
 {
     //create an instance of the class we want to create
     clsProduct AProduct = new clsProduct();
     //Create test data 
     string AProductManufacturer = "AJazz";
     //assign the data to the property
     AProduct.ProductManufacturer = AProductManufacturer;
     //two values are the same
     Assert.AreEqual(AProduct.ProductManufacturer, AProductManufacturer);
 }
Esempio n. 12
0
 public void TestProductsInStockFound()
 {
     //create an instance of the class we want to create
     clsProduct AProduct = new clsProduct();
     //Boolean variable to store the result of the validation
     Boolean Found = false;
     //boolean variable to record if data is OK (assume it is)
     Boolean OK = true;
     //create some test data to use with the method
     Int32 ProductNo = 1;
     //invoke the mothod
     Found = AProduct.Find(ProductNo);
     //chech the address no
     if (AProduct.ProductsInStock != 8)
     {
         OK = false;
     }
     //test to see if the result is correct
     Assert.IsTrue(OK);
 }
Esempio n. 13
0
 public void TestProductNoFound()
 {
     //create an instance of the class we want to create
     clsProduct AProduct = new clsProduct();
     //boolean variable to store the result of the search
     Boolean Found = false;
     //boolean variable to record if data is OK (assume it is)
     Boolean OK = true;
     //create some test data to use with the method
     Int32 ProductNo = 2;
     //invoke the method
     Found = AProduct.Find(ProductNo);
     //check the product no
     if (Convert.ToInt32(AProduct.ProductNo) != 2)
     {
         OK = false;
     }
     //test to see that result is correct
     Assert.IsTrue(OK);
 }
Esempio n. 14
0
 public void FindMethodOK()
 {
     //create an instance of the class we want to create
     clsProduct AProduct = new clsProduct();
     //boolean variable to store the result of the validation
     Boolean Found = false;
     //create some test data to use with the method
     Int32 ProductNo = 2;            
     //invoke the method
     Found = AProduct.Find(ProductNo);
     //test to see that the result is correct            
     Assert.IsTrue(Found);
 }
Esempio n. 15
0
 public void ProductsInStock()
 {
     //create an instance of the class we want to create
     clsProduct AProduct = new clsProduct();
     //Create test data 
     int AStock = 8;
     //assign the data to the property
     AProduct.ProductsInStock = AStock;
     //two values are the same
     Assert.AreEqual(AProduct.ProductsInStock, AStock);
 }