public void When_Calculate_Cart_With_Two_Products_Price_12_95_and_110_95_Should_Be_Total_equal_173_90() { var _cartOptions = new DbContextOptionsBuilder <CartsContext>().UseInMemoryDatabase("carts").Options; var _cartContext = new CartsContext(_cartOptions); var _productOptions = new DbContextOptionsBuilder <ProductsContext>().UseInMemoryDatabase("products").Options; var _productContext = new ProductsContext(_productOptions); CartsModel cartModel = new CartsModel { userId = 1, createDatetime = DateTime.Now, updateDatetime = DateTime.Now }; List <ProductInCartModel> productsInCart = new List <ProductInCartModel>(); productsInCart.Add(new ProductInCartModel { price = 12.95M, quantity = 1 }); productsInCart.Add(new ProductInCartModel { price = 110.95M, quantity = 1 }); CartsService cartsService = new CartsService(_cartContext, _productContext); var actualResult = cartsService.calculate(cartModel, productsInCart); Assert.Equal(123.90M, actualResult.subtotal); Assert.Equal(148.90M, actualResult.total); }
public void When_Calculate_Cart_With_One_Product_Price_119_95_Should_Be_Total_equal_169_95() { var _cartOptions = new DbContextOptionsBuilder <CartsContext>().UseInMemoryDatabase("calculate_carts").Options; var _cartContext = new CartsContext(_cartOptions); var _productOptions = new DbContextOptionsBuilder <ProductsContext>().UseInMemoryDatabase("calculate_products").Options; var _productContext = new ProductsContext(_productOptions); CartsModel cartModel = new CartsModel { userId = 1, createDatetime = DateTime.Now, updateDatetime = DateTime.Now }; List <ProductInCartModel> productsInCart = new List <ProductInCartModel>(); productsInCart.Add(new ProductInCartModel { price = (Decimal)119.95, quantity = 1 }); CartsService cartsService = new CartsService(_cartContext, _productContext); var actualResult = cartsService.calculate(cartModel, productsInCart); Assert.Equal((Decimal)119.95, actualResult.subtotal); Assert.Equal((Decimal)144.95, actualResult.total); }
public void When_Calculate_Cart_With_Zero_Product_Should_Be_Total_equal_0() { var _cartOptions = new DbContextOptionsBuilder <CartsContext>().UseInMemoryDatabase("carts").Options; var _cartContext = new CartsContext(_cartOptions); var _productOptions = new DbContextOptionsBuilder <ProductsContext>().UseInMemoryDatabase("products").Options; var _productContext = new ProductsContext(_productOptions); CartsModel cartModel = new CartsModel { userId = 1, createDatetime = DateTime.Now, updateDatetime = DateTime.Now }; List <ProductInCartModel> productsInCart = new List <ProductInCartModel>(); CartsService cartsService = new CartsService(_cartContext, _productContext); var actualResult = cartsService.calculate(cartModel, productsInCart); Assert.Equal(0.00M, actualResult.subtotal); Assert.Equal(0.00M, actualResult.total); }
public void When_Calculate_Cart_With_Zero_Product_Should_Be_Total_equal_0() { var actualResult = _cartsService.calculate(_cartModel, _productsInCart); Assert.Equal(0.00M, actualResult.total); }