public void When_Create_New_Cart_With_Product_ID2_And_Quantity2_And_Should_Be_Get_CartID1() { var _cartOptions = new DbContextOptionsBuilder <CartsContext>().UseInMemoryDatabase("create_new_cart_carts").Options; var _cartContext = new CartsContext(_cartOptions); var _productOptions = new DbContextOptionsBuilder <ProductsContext>().UseInMemoryDatabase("create_new_cart_products").Options; var _productContext = new ProductsContext(_productOptions); ProductsModel productsData = new ProductsModel { id = 2, name = "43 Piece dinner Set", price = (Decimal)12.95, availability = "InStock", stockAvailability = 10, age = "3_to_5", gender = "FEMALE", brand = "CoolKidz" }; _productContext.Products.Add(productsData); _productContext.SaveChanges(); CartsService cartsService = new CartsService(_cartContext, _productContext); var actualResult = cartsService.add(productsData, 1); Assert.Equal(1, actualResult.id); }
public void When_Create_New_Cart_With_43_Piece_Dinner_Set_With_1_Qty_Should_Return_Cart_Detail_With_43_Piece_Dinner_Set() { ProductsModel adding_product = _fixture._2_43_Piece_dinner_Set; int adding_quantity = 1; CartsContext _cartContext = createCartsContext("create_new_cart_carts2"); CartsModel expectedCart = createCartInfo(adding_product, adding_quantity); CartsService cartService = new CartsService(_cartContext, _productContext); AddCartOutputModel cartOutput = cartService.add(adding_product, adding_quantity); CartsModel actualCart = cartService.getCart(cartOutput.id, DEFAULT_USER_ID); Assert.Equal(expectedCart.CartProducts, actualCart.CartProducts); Assert.Equal(expectedCart.userId, actualCart.userId); Assert.Equal(expectedCart.total, actualCart.total); Assert.Equal(expectedCart.subtotal, actualCart.subtotal); Assert.Equal(expectedCart.shippingFee, actualCart.shippingFee); Assert.Equal(expectedCart.shippingMethod, actualCart.shippingMethod); }