public void AddMethodOK() { //create an instance of the class we want to creeate clsSaleCollection Sales = new clsSaleCollection(); //create the item of test data clsSaleItem TestItem = new clsSaleItem(); //var to store the primary key Int32 PrimaryKey = 1; //set its properties TestItem.ItemID = 3; TestItem.ItemPrice = 1.99m; TestItem.Quantity = 1; TestItem.SaleID = 2; TestItem.DateAdded = DateTime.Now.Date; //set ThisSale to the testdata Sales.ThisSale = TestItem; //add the record PrimaryKey = Sales.Add(); //set the primary key of the test data TestItem.ItemID = PrimaryKey; //find the record Sales.ThisSale.Find(PrimaryKey); //test to see that the two values are the same Assert.AreEqual(Sales.ThisSale, TestItem); }
public void DeleteMethodOK() { //create an instance of the class we want to create clsSaleCollection Sales = new clsSaleCollection(); //create the item of test data clsSaleItem TestItem = new clsSaleItem(); //var to store the primary key Int32 PrimaryKey = 1; //set its properties TestItem.ItemID = 4; TestItem.ItemPrice = 1.99m; TestItem.Quantity = 1; TestItem.SaleID = 2; TestItem.DateAdded = DateTime.Now.Date; //set ThisSale to the testdata Sales.ThisSale = TestItem; //add the record PrimaryKey = Sales.Add(); //set the primary key of the test data TestItem.ItemID = PrimaryKey; //find the record Sales.ThisSale.Find(PrimaryKey); //delete the record Sales.Delete(); //now find the record Boolean Found = Sales.ThisSale.Find(PrimaryKey); //test to see that the record was not found Assert.IsFalse(Found); }
public void InstanceOK() { //create an instance of the class we want to create clsSaleItem ASaleItem = new clsSaleItem(); //test to see that it exists Assert.IsNotNull(ASaleItem); }
public void DateAddedPropertyOK() { clsSaleItem ASaleItem = new clsSaleItem(); //create some test data to assign to the property DateTime SomeDateAdded = Convert.ToDateTime("05/04/2018"); //assign the data to the property ASaleItem.DateAdded = SomeDateAdded; //test //test to see that the two values are the same Assert.AreEqual(ASaleItem.DateAdded, SomeDateAdded); }
public void SaleIDPropertyOK() { //create an instance of the class we want to create clsSaleItem ASaleItem = new clsSaleItem(); //create some test data to assign to the property int SomeSaleID = 1; //assign the data to the property ASaleItem.SaleID = SomeSaleID; //test to see that the two values are the same Assert.AreEqual(ASaleItem.SaleID, SomeSaleID); }
public void QuantityPropertyOK() { //create an instance of the class we want to create clsSaleItem ASaleItem = new clsSaleItem(); //create some test data to assign to the property int SomeQuantity = 2; //assign the data to the property ASaleItem.Quantity = SomeQuantity; //test to see that the two values are the same Assert.AreEqual(ASaleItem.Quantity, SomeQuantity); }
public void ItemPricePropertyOK() { //create an instance of the class we want to create clsSaleItem ASaleItem = new clsSaleItem(); //create some test data to assign to the property decimal SomeItemPrice = 1.99m; //assign the data to the property ASaleItem.ItemPrice = SomeItemPrice; //test to see that the two values are the same Assert.AreEqual(ASaleItem.ItemPrice, SomeItemPrice); }
public void DateAddedMinPlusOne() { //create an instance of the class we want to create clsSaleItem ASaleItem = new clsSaleItem(); //boolean variable to store the result of the validation String Error = ""; //create some test data to pass to the method int ItemID = 1; decimal ItemPrice = 1.99m; int Quantity = 2; int SaleID = 1; DateTime DateAdded = (DateTime.Now.Date).AddDays(1); //invoke the method Error = ASaleItem.Valid(ItemID, ItemPrice, Quantity, SaleID, DateAdded); //test to see that the result is correct Assert.AreNotEqual(Error, ""); }
public void ValidMethodOK() { //create an instance of the class we want to create clsSaleItem ASaleItem = new clsSaleItem(); //string variable to store any error message string Error = ""; //create some test data to pass to the method int ItemID = 1; decimal ItemPrice = 1.99m; int Quantity = 2; int SaleID = 1; DateTime DateAdded = DateTime.Now.Date; //invoke the method Error = ASaleItem.Valid(ItemID, ItemPrice, Quantity, SaleID, DateAdded); //test to see that the result is correct Assert.AreEqual(Error, ""); }
private void btnAdd_Click(object sender, EventArgs e) { clsSaleCollection Sales = new clsSaleCollection(); clsSaleItem AddedItem = new clsSaleItem(); //var to store the primary key Int32 PrimaryKey = 1; AddedItem.ItemID = Convert.ToInt32(txtItemID.Text); AddedItem.ItemPrice = Convert.ToDecimal(txtItemPrice.Text); AddedItem.Quantity = Convert.ToInt32(txtQuantity.Text); AddedItem.SaleID = Convert.ToInt32(txtSaleID.Text); AddedItem.DateAdded = DateTime.Now.Date; Sales.ThisSale = AddedItem; //add the record PrimaryKey = Sales.Add(); formSales.DisplaySaleItems(); this.Close(); }
public void CountMatchesList() { //create an instance of the class we want to create clsSaleCollection Sales = new clsSaleCollection(); //create some test data to assign to the property //in this case the data needs to be a list of objects List <clsSaleItem> TestList = new List <clsSaleItem>(); //add an item to the list //create the item of test data clsSaleItem TestItem = new clsSaleItem(); //set its properties TestItem.ItemID = 1; TestItem.ItemPrice = 1.99m; TestItem.Quantity = 1; TestItem.SaleID = 2; TestItem.DateAdded = DateTime.Now.Date; //add the item to the test list TestList.Add(TestItem); //assign the data to the property Sales.SaleItems = TestList; //test to see that the two values are the same Assert.AreEqual(Sales.Count, TestList.Count); }
public void UpdateMethodOK() { //create an instance of the class we want to create clsSaleCollection Sales = new clsSaleCollection(); //create the item of test data clsSaleItem TestItem = new clsSaleItem(); //var to store the primary key Int32 PrimaryKey = 1; //set its properties TestItem.ItemID = 5; TestItem.ItemPrice = 1.99m; TestItem.Quantity = 1; TestItem.SaleID = 2; TestItem.DateAdded = DateTime.Now.Date; //set ThisSale to the testdata Sales.ThisSale = TestItem; //add the record PrimaryKey = Sales.Add(); //set the primary key of the test data TestItem.ItemID = PrimaryKey; //modify the test data TestItem.ItemID = 6; TestItem.ItemPrice = 58.99m; TestItem.Quantity = 3; TestItem.SaleID = 3; TestItem.DateAdded = DateTime.Now.Date; //set the record based on the new test data Sales.ThisSale = TestItem; //update the record Sales.Update(); //find the record Sales.ThisSale.Find(PrimaryKey); //test to see ThisSale matches the test data Assert.AreEqual(Sales.ThisSale, TestItem); }