public async void TestReadCart() { DbContextOptions <CreaturesDbcontext> options = new DbContextOptionsBuilder <CreaturesDbcontext>().UseInMemoryDatabase("ReadCart").Options; using (CreaturesDbcontext context = new CreaturesDbcontext(options)) { Cart testCart4 = new Cart(); testCart4.ID = 1; testCart4.UserID = "aUserID"; CartManagementService cartService = new CartManagementService(context); await cartService.Create(testCart4); var cart2Answer = await cartService.GetCart("aUserID"); Assert.Equal(testCart4, cart2Answer); } }
public async void TestCreateCart() { DbContextOptions <CreaturesDbcontext> options = new DbContextOptionsBuilder <CreaturesDbcontext>().UseInMemoryDatabase("CreateCart").Options; using (CreaturesDbcontext context = new CreaturesDbcontext(options)) { Cart testCart3 = new Cart(); testCart3.ID = 1; testCart3.UserID = "aUserID"; CartManagementService cartService = new CartManagementService(context); await cartService.Create(testCart3); var cart1Answer = context.Carts.FirstOrDefault(c => c.ID == testCart3.ID); Assert.Equal(testCart3, cart1Answer); } }