public async void AbleToUpdateQuantity() { DbContextOptions <StoreDbContext> options = new DbContextOptionsBuilder <StoreDbContext>() .UseInMemoryDatabase("AbleToUpdateQuantity") .Options; using (StoreDbContext storeDb = new StoreDbContext(options)) { CartItemsService cis = new CartItemsService(storeDb); CartItems ci = new CartItems() { ProductID = 1, CartsID = 1, Quantity = 420 }; await cis.CreateCartItems(ci); ci.Quantity = 69; await cis.UpdateCartItems(ci); var blazeIt = await cis.GetCartItemsById(ci.ID); Assert.Equal(69, blazeIt.Quantity); } }
public async void AbleToDeleteCartItem() { DbContextOptions <StoreDbContext> options = new DbContextOptionsBuilder <StoreDbContext>() .UseInMemoryDatabase("AbleToDeleteCartItem") .Options; using (StoreDbContext storeDb = new StoreDbContext(options)) { CartItemsService cis = new CartItemsService(storeDb); CartItems ci = new CartItems() { ProductID = 1, CartsID = 1, Quantity = 200 }; await cis.CreateCartItems(ci); await cis.DeleteCartItems(ci.ID); var result = await cis.GetCartItemsById(ci.ID); Assert.Null(result); } }
public CartItemsController(IConfiguration configuration) { this.connectionString = configuration.GetConnectionString("ConnectionString"); this.cartItemsService = new CartItemsService(new CartItemsRepository(connectionString)); }
public CartItemsServiceTests() { _cartItemsServiceMock = new CartItemsService(_cartRepostitoryMock.Object); }