public async void TestCreateOrder() { DbContextOptions <CreaturesDbcontext> options = new DbContextOptionsBuilder <CreaturesDbcontext>().UseInMemoryDatabase("CreateOrder").Options; using (CreaturesDbcontext context = new CreaturesDbcontext(options)) { Order testOrder5 = new Order(); testOrder5.ID = 1; testOrder5.UserID = "aUserID"; testOrder5.Totalprice = 30; OrderManagementService orderService = new OrderManagementService(context); await orderService.CreateOrder(testOrder5); var order1Answer = context.OrderTable.FirstOrDefault(c => c.ID == testOrder5.ID); Assert.Equal(testOrder5, order1Answer); } }
public async void TestGetOrder() { DbContextOptions <CreaturesDbcontext> options = new DbContextOptionsBuilder <CreaturesDbcontext>().UseInMemoryDatabase("GetOrder").Options; using (CreaturesDbcontext context = new CreaturesDbcontext(options)) { Order testOrder6 = new Order(); testOrder6.ID = 1; testOrder6.UserID = "aUserID"; testOrder6.Totalprice = 300; OrderManagementService orderService = new OrderManagementService(context); await orderService.CreateOrder(testOrder6); var order2Answer = await orderService.GetOrder("aUserID"); Assert.Equal(testOrder6, order2Answer[0]); } }
public IHttpActionResult CreateOrder(Order order) { return(Ok(order_service.CreateOrder(order))); }