Beispiel #1
0
 public void ProductInstanceOK()
 {
     //create an instance of the product class
     clsProduct TestProduct = new clsProduct();
     //test to see that exists
     Assert.IsNotNull(TestProduct);
 }
Beispiel #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++;
     }
 }
Beispiel #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);
 }
Beispiel #4
0
 public void ProductOK()
 {
     clsProduct TestProduct = new clsProduct();
     string TestData = "Keyboards";
     TestProduct.Product = TestData;
     Assert.AreEqual(TestProduct.Product, TestData);
 }
Beispiel #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);
 }
Beispiel #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);
 }
Beispiel #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);
 }
Beispiel #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);
 }
Beispiel #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);
 }
Beispiel #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);
 }
Beispiel #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);
 }
Beispiel #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);
 }
Beispiel #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);
 }
Beispiel #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);
 }
Beispiel #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);
 }