public async void TestGetAllOrdereItems() { DbContextOptions <CreaturesDbcontext> options = new DbContextOptionsBuilder <CreaturesDbcontext>().UseInMemoryDatabase("GetAllOrderedItems").Options; using (CreaturesDbcontext context = new CreaturesDbcontext(options)) { OrderedItems testOrderedItem6 = new OrderedItems(); testOrderedItem6.ID = 1; testOrderedItem6.OrderID = 1; OrderedItems testOrderedItem7 = new OrderedItems(); testOrderedItem7.ID = 2; testOrderedItem7.OrderID = 1; OrderedItemsManagementService orderedItemsService = new OrderedItemsManagementService(context); await orderedItemsService.CreateOrderedItem(testOrderedItem6); await orderedItemsService.CreateOrderedItem(testOrderedItem7); var orderedItems2Answer = await orderedItemsService.GetAllOrderedItems(1); Assert.Equal(2, orderedItems2Answer.Count); } }
public async void TestCreateOrdereItems() { DbContextOptions <CreaturesDbcontext> options = new DbContextOptionsBuilder <CreaturesDbcontext>().UseInMemoryDatabase("CreateOrderedItems").Options; using (CreaturesDbcontext context = new CreaturesDbcontext(options)) { OrderedItems testOrderedItem5 = new OrderedItems(); testOrderedItem5.ID = 1; testOrderedItem5.OrderID = 1; OrderedItemsManagementService orderedItemsService = new OrderedItemsManagementService(context); await orderedItemsService.CreateOrderedItem(testOrderedItem5); var orderedItems1Answer = context.OrderedItemsTable.FirstOrDefault(c => c.ID == testOrderedItem5.ID); Assert.Equal(testOrderedItem5, orderedItems1Answer); } }