Beispiel #1
0
        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);
        }
Beispiel #2
0
        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);
        }