public void GetOrder() { IOrderRepo repo = new TestOrderRepo(); DateTime date = new DateTime(2000, 11, 11); OrderMgr orderMgr = new OrderMgr(repo); List <Order> orders = orderMgr.GetOrders(date); Assert.IsNotNull(orders); }
public void AddOrder() { IOrderRepo repo = new TestOrderRepo(); DateTime date = new DateTime(2000, 11, 11); OrderMgr orderMgr = new OrderMgr(repo); Order order = new Order(); List <Order> orders = orderMgr.GetOrders(date); orderMgr.AddOrder(order); Assert.AreEqual(order, orders.Last()); }
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); }
public OrderManager() { string mode = ConfigurationManager.AppSettings["appName"]; if (mode == "Test") { var repo = new TestOrderRepo(); _repo = repo; } else { var repo = new ProdOrderRepo(); _repo = repo; _taxrepo = new TaxRepo(); _productrepo = new ProductRepo(); } }
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); }
public void TestThrowsMissingEntry(int orderNum, int year, int month, int day) { IOrderRepo orderRepo = new TestOrderRepo(); Assert.Throws(typeof(InvalidOperationException), new TestDelegate(() => orderRepo.GetSpecificOrder(orderNum, new DateTime(year, month, day)))); }