Esempio n. 1
0
        public void RemoveOrderTest(int orderNum, int year, int month, int day)
        {
            IOrderRepo orderRepo = new TestOrderRepo();

            Assert.DoesNotThrow(new TestDelegate(() => orderRepo.GetSpecificOrder(orderNum, new DateTime(year, month, day))));
            Order backup = orderRepo.GetSpecificOrder(orderNum, new DateTime(year, month, day));

            orderRepo.RemoveOrder(orderRepo.GetSpecificOrder(orderNum, new DateTime(year, month, day)));
            Assert.Throws(typeof(InvalidOperationException), new TestDelegate(() => orderRepo.GetSpecificOrder(orderNum, new DateTime(year, month, day))));

            //Clean up after itself:
            orderRepo.SaveOrder(backup);
        }
Esempio n. 2
0
        public void SaveOrderTest(int orderNum, int year, int month, int day)
        {
            IOrderRepo orderRepo   = new TestOrderRepo();
            Product    testProduct = new Product("whoa", 1.0m, 1.0m);
            DateTime   testDate    = new DateTime(year, month, day);
            State      testState   = new State("whoa", "wh", 1.0m);

            Order testOrder = new Order(testDate, "testName", testState, testProduct, 100.0m);

            testOrder.UpdateNum(orderNum);

            Assert.Throws(typeof(InvalidOperationException), new TestDelegate(() => orderRepo.GetSpecificOrder(orderNum, testDate)));

            orderRepo.SaveOrder(testOrder);
            Assert.DoesNotThrow(new TestDelegate(() => orderRepo.GetSpecificOrder(orderNum, testDate)));

            //clean up after itself:
            orderRepo.RemoveOrder(testOrder);
        }