public async Task WishlistRepository_RemoveBookFromUserWishlist() { // arrange const string username = "******"; const string bookName = "Test Book"; const string authorName = "The Author"; long isbn; int originalWishlistCount; const int userId = 1; const int bookId = 1; using var contextFactory = new TestLooseLeafContextFactory(); using (LooseLeafContext arrangeContext = contextFactory.CreateContext()) { await contextFactory.CreateUser(arrangeContext, username); isbn = await contextFactory.CreateBook(arrangeContext, bookName, authorName); await arrangeContext.Wishlists.AddAsync(new DataAccess.Wishlist() { UserId = 1, BookId = 1 }); await arrangeContext.SaveChangesAsync(); } // act using (LooseLeafContext actContext = contextFactory.CreateContext()) { IWishlistRepository wishlistRepository = new WishlistRepository(actContext); originalWishlistCount = actContext.Wishlists.Count(); await wishlistRepository.RemoveBookFromUserWishlist(userId, bookId); await actContext.SaveChangesAsync(); } // assert using LooseLeafContext assertContext = contextFactory.CreateContext(); Assert.Equal(0, assertContext.Wishlists.Count()); Assert.Equal(1, originalWishlistCount); }