public void AddMethodOK() { //create an instance of the class we want to create clsOrderCollection AllOrders = new clsOrderCollection(); //create the item of test data clsOrder TestItem = new clsOrder(); //var to store the primary key Int32 PrimaryKey = 0; //set its properties TestItem.OrderId = 123; TestItem.ItemName = "Test Item"; TestItem.Price = 22.22; TestItem.DateOrderMade = DateTime.Now.Date; TestItem.ItemShipped = true; //set ThisOrder to the test data AllOrders.ThisOrder = TestItem; //add the record PrimaryKey = AllOrders.Add(); //set the primary key of the test data TestItem.OrderId = PrimaryKey; //find the record AllOrders.ThisOrder.Find(PrimaryKey); //test to see that the two values are the same Assert.AreEqual(AllOrders.ThisOrder, TestItem); }
public void UpdateMethodOK() { clsOrderCollection OrderList = new clsOrderCollection(); clsOrder AnOrder = new clsOrder(); Int32 PrimaryKey = 0; AnOrder.CustomerNum = 1; AnOrder.ItemNum = 1; AnOrder.DateFinalised = DateTime.Now.Date; AnOrder.StandaloneOrSet = "Standalone"; AnOrder.TotalPrice = 2.98; AnOrder.Quantity = 2; AnOrder.ReadyForShipping = true; OrderList.ThisOrder = AnOrder; PrimaryKey = OrderList.Add(); AnOrder.OrderNum = PrimaryKey; AnOrder.CustomerNum = 2; AnOrder.ItemNum = 4; AnOrder.DateFinalised = DateTime.Now.Date; AnOrder.StandaloneOrSet = "Set"; AnOrder.TotalPrice = 5.99; AnOrder.Quantity = 1; AnOrder.ReadyForShipping = true; OrderList.ThisOrder = AnOrder; OrderList.Update(); OrderList.ThisOrder.Find(PrimaryKey); Assert.AreEqual(OrderList.ThisOrder, AnOrder); }
public void AddMethodOK() { clsOrderCollection AllOrders = new clsOrderCollection(); clsOrder AnOrder = new clsOrder(); Int32 PrimaryKey = 0; AnOrder.CustomerNum = 5; AnOrder.ItemNum = 6; AnOrder.DateFinalised = DateTime.Now.Date; AnOrder.StandaloneOrSet = "Standalone"; AnOrder.TotalPrice = 6.98; AnOrder.Quantity = 2; AnOrder.ReadyForShipping = true; AllOrders.ThisOrder = AnOrder; PrimaryKey = AllOrders.Add(); AnOrder.OrderNum = PrimaryKey; AllOrders.ThisOrder.Find(PrimaryKey); Assert.AreEqual(AllOrders.ThisOrder, AnOrder); }
public void DeleteMethodOK() { clsOrderCollection OrderList = new clsOrderCollection(); clsOrder AnOrder = new clsOrder(); Int32 PrimaryKey = 0; AnOrder.CustomerNum = 1; AnOrder.ItemNum = 1; AnOrder.DateFinalised = DateTime.Now.Date; AnOrder.StandaloneOrSet = "Standalone"; AnOrder.TotalPrice = 2.98; AnOrder.Quantity = 2; AnOrder.ReadyForShipping = true; OrderList.ThisOrder = AnOrder; PrimaryKey = OrderList.Add(); AnOrder.OrderNum = PrimaryKey; OrderList.ThisOrder.Find(PrimaryKey); OrderList.Delete(); Boolean Found = OrderList.ThisOrder.Find(PrimaryKey); Assert.IsFalse(Found); }
public void DeleteMethodOK() { //create an instance of the class we want to create clsOrderCollection AllOrders = new clsOrderCollection(); //create item of test data clsOrder TestItem = new clsOrder(); //var to store the primary key Int32 PrimaryKey = 0; //set its properties TestItem.OrderId = 1234; TestItem.ItemName = "Test Item3"; TestItem.Price = 33.22; TestItem.DateOrderMade = DateTime.Now.Date; TestItem.ItemShipped = true; //set ThisOrder to the test data AllOrders.ThisOrder = TestItem; //add the record PrimaryKey = AllOrders.Add(); //set the primary key of the test data TestItem.OrderId = PrimaryKey; //find the record AllOrders.ThisOrder.Find(PrimaryKey); //delete the record AllOrders.Delete(); //now find the record Boolean Found = AllOrders.ThisOrder.Find(PrimaryKey); //test to see that the record was not found Assert.IsFalse(Found); }