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); }
public void InstantiationOk() { //create an instance of the class clsStockItem AStockItem = new clsStockItem(); Assert.IsNotNull(AStockItem); }
//used to test the presence of the valid method public void PriceValidOK() { //create and instance of the class clsStockItem AStockItem = new clsStockItem(); Boolean OK; //test to see if the valid method exists OK = AStockItem.PriceValid("10.10"); Assert.IsTrue(OK); }
//used to test the presence of the valid method public void PriceMinLessOne() { //create and instance of the class clsStockItem AStockItem = new clsStockItem(); Boolean OK; //test to see if the valid method exists OK = AStockItem.PriceValid("-0.01"); Assert.IsFalse(OK); }
//used to test the Item Price property of the class public void ItemPrice() { //create an instance of the class clsStockItem AStockItem = new clsStockItem(); //create a variable to store the price of an item decimal SomePrice; //assign an item price to the variable SomePrice = 10.00M; //try to send some data to the ItemPrice property AStockItem.ItemPrice = 10; //check to see that the data in the variable and the propery are the sam Assert.AreEqual(AStockItem.ItemPrice, SomePrice); }
//public void FindAllStockItems() public clsStockCollection() { //re-set the connection clsDataConnection myDB = new clsDataConnection(); //execute the stored procedure myDB.Execute("sproc_tblStockItem_SelectAll"); //get the count of records Int32 recordCount = myDB.Count; //var to store the index Int32 Index = 0; //while there are still records to process while (Index < myDB.Count) ////var to store the user number of the current record //Int32 StockNo; ////var to flag that user was found //Boolean StockFound; { //create an instance of the stock item class clsStockItem AStockItem = new clsStockItem(); //get the stock name AStockItem.StockName = myDB.DataTable.Rows[Index]["StockName"].ToString(); //get the primary key AStockItem.StockNo = Convert.ToInt32(myDB.DataTable.Rows[Index]["StockNo"]); //increment the index Index++; ////get the user number from the database //StockNo = Convert.ToInt32(myDB.DataTable.Rows[Index]["StockNo"]); ////find the user by invoking the find method //StockFound = NewItem.Find(StockNo); //if (StockFound == true) //{ // //add the user to the list allStock.Add(AStockItem); //} } }
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); }
public void TestStockCodeFound() { //create an instance of the class clsStockItem AStockItem = new clsStockItem(); //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 StockCode = 3; //invoke the method Found = AStockItem.Find(StockCode); //check the stock no if (AStockItem.StockNo != 3) { OK = false; } //test to see that the result is correct Assert.IsTrue(OK); }
public void ItemPricePropertyOK() { //create an instance of the class clsStockItem AStockItem = new clsStockItem(); //create some test data to assign to the property decimal TestData = 1; //assign the data to the property AStockItem.ItemPrice = TestData; //test to see that the two values are the same Assert.AreEqual(AStockItem.ItemPrice, TestData); }
//used to test the presence of the valid method public void SupplierNameValidOK() { //create and instance of the class clsStockItem AStockItem = new clsStockItem(); Boolean OK; //test to see if the valid method exists OK = AStockItem.SupplierNameValid("12111"); Assert.IsTrue(OK); }
public void SupplierNameExtremeMax() { //create an instance of the class clsStockItem AStockItem = new clsStockItem(); //create a variable to record the result of the validation test Boolean OK; //create a variable to store the test data string SomeText = ""; //pad the data to the required number of characters SomeText = SomeText.PadLeft(1000); //test the valid method with a two character string OK = AStockItem.SupplierNameValid(SomeText); //assert that the outcome should be true Assert.IsFalse(OK); }
//used to test the presence of the valid method public void StockNameMinPlusOne() { //create and instance of the class clsStockItem AStockItem = new clsStockItem(); Boolean OK; //test to see if the valid method exists OK = AStockItem.StockNameValid("555555"); Assert.IsTrue(OK); }
public void SupplierName() { //create an instance of the class clsStockItem AStockItem = new clsStockItem(); //create a variable to store the code of an item string SomeSupplier; //assign an item code to the variable SomeSupplier = "12354"; //try to send some data to the StockCode property AStockItem.SupplierName = SomeSupplier; //check to see that the data in the variable and the property are the sam Assert.AreEqual(AStockItem.SupplierName, SomeSupplier); }
public void StockCode() { //create an instance of the class clsStockItem AStockItem = new clsStockItem(); //create a variable to store the code of an item Int32 SomeCode; //assign an item code to the variable SomeCode = 12345; //try to send some data to the StockCode property AStockItem.StockNo = SomeCode; //check to see that the data in the variable and the propery are the sam Assert.AreEqual(AStockItem.StockNo, SomeCode); }
public void StockLevelMaxLessOne() { //create an instance of the class clsStockItem AStockItem = new clsStockItem(); //create a variable to record the result of the validation test Boolean OK; //create a variable to store the test data string SomeText = ""; //pad the data to the required number of characters SomeText = SomeText.PadLeft(999); //test the valid method with a two character string OK = AStockItem.StockLevelValid(SomeText); //assert that the outcome should be true Assert.IsTrue(OK); }
//used to test the presence of the valid method public void StockItemDescriptionMinLessOne() { //create and instance of the class clsStockItem AStockItem = new clsStockItem(); Boolean OK; //test to see if the valid method exists OK = AStockItem.StockItemDescriptionValid("4444"); Assert.IsFalse(OK); }
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); }
public void StockItemDescription() { //create an instance of the class clsStockItem AStockItem = new clsStockItem(); //create a variable to store the description of an item string SomeDescription; //assign an item price to the variable SomeDescription = "Windows 2010"; //try to send some data to the StockItemDescription property AStockItem.StockItemDescription = SomeDescription; //check to see that the data in the variable and the property are the sam Assert.AreEqual(AStockItem.StockItemDescription, SomeDescription); }
//used to test the presence of the valid method public void StockItemDescriptionValidOK() { //create and instance of the class clsStockItem AStockItem = new clsStockItem(); Boolean OK; //test to see if the valid method exists OK = AStockItem.StockItemDescriptionValid("PCPackage"); Assert.IsTrue(OK); }
//used to test the Stock Level property of the class public void StockLevel() { //create an instance of the class clsStockItem AStockItem = new clsStockItem(); //create a variable to store the stock level of an item Int32 SomeLevel; //assign an stock level to the variable SomeLevel = 12; //try to send some data to the StockLevel property AStockItem.StockLevel = 12; //check to see that the data in the variable and the propery are the same Assert.AreEqual(AStockItem.StockLevel, SomeLevel); }
public void StockLevelPropertyOK() { //create an instance of the class clsStockItem AStockItem = new clsStockItem(); //create some test data to assign to the property Int32 TestData = 1; //assign the data to the property AStockItem.StockLevel = TestData; //test to see that the two values are the same Assert.AreEqual(AStockItem.StockLevel, TestData); }
//used to test the presence of the valid method public void StockCodeMaxBoundaryLessOne() { //create and instance of the class clsStockItem AStockItem = new clsStockItem(); Boolean OK; //test to see if the valid method exists OK = AStockItem.StockCodeValid("7"); Assert.IsTrue(OK); }
public void StockItemDescriptionPropertyOK() { //create an instance of the class clsStockItem AStockItem = new clsStockItem(); //create some test data to assign to the property string TestData = "something here"; //assign the data to the property AStockItem.StockItemDescription = TestData; //test to see that the two values are the same Assert.AreEqual(AStockItem.StockItemDescription, TestData); }
//used to test the presence of the valid method public void StockLevelMinBoundary() { //create and instance of the class clsStockItem AStockItem = new clsStockItem(); Boolean OK; //test to see if the valid method exists OK = AStockItem.StockLevelValid("0"); Assert.IsTrue(OK); }
//test that the StockItemDescription validation throws an error //when StockItemDescription is more than 8 characters public void StockItemDescriptionMaxPlusOne() { //create and instance of the class clsStockItem AstockItem = new clsStockItem(); //create a varaible to record the result of the validation test Boolean OK; //create a variable to store the test data string SomeText = ""; //pad the data to the required number of characters SomeText = SomeText.PadLeft(101); //test the valid method with a two character string OK = AstockItem.StockCodeValid(SomeText); //assert that the outcome should be true Assert.IsFalse(OK); }
public void SupplierNamePropertyOK() { //create an instance of the class clsStockItem AStockItem = new clsStockItem(); //create some test data to assign to the property String TestData = "someone"; //assign the data to the property AStockItem.SupplierName = TestData; //test to see that the two values are the same Assert.AreEqual(AStockItem.SupplierName, TestData); }
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); }
public void StockName() { //create an instance of the class clsStockItem AStockItem = new clsStockItem(); //create a variable to store the code of an item string SomeName; //assign an item name to the variable SomeName = "Windows 2010"; //try to send some data to the StockName property AStockItem.StockName = SomeName; //check to see that the data in the variable and the //property are the same Assert.AreEqual(AStockItem.StockName, SomeName); }