public void CalcPPW_VariousPricesAndAmounts_1() { var ppw = new PricePerWeigth() { Price = 62.57M, Amount = 15.6M }; //arrange decimal result = ppw.Calc(); //act Assert.AreEqual(result, 976.09M); //assert }
public void CalcPPW_VariousPricesAndAmounts_2() { var ppw = new PricePerWeigth() { Price = 105.77M, Amount = 5.9M }; decimal result = ppw.Calc(); Assert.AreEqual(result, 624.04M); }
private void CreateShopTable(List <Cart> purchasedList, out decimal subTotal) { subTotal = 0.00M; var productModel = new ProductModel(); foreach (var cart in purchasedList) { var product = productModel.GetProduct(cart.ProductId); var ppw = new PricePerWeigth() { Price = product.Price, Amount = cart.Amount }; subTotal += ppw.Calc(); var ibtProductImage = new ImageButton { ImageUrl = String.Format("~/Images/Products/{0}", product.Image), PostBackUrl = String.Format("~/Pages/Product.aspx?id={0}", product.Id) }; var lbtDelete = new LinkButton { PostBackUrl = String.Format("~/Pages/ShoppingCarts.aspx?productId={0}", cart.Id), Text = "Удалить из корзины", ID = "del" + cart.Id }; lbtDelete.Click += Delete_Item; var table = new Table { CssClass = "cartTable" }; TableCell[] cells = new TableCell[6]; for (int i = 0; i < cells.GetLength(0); i++) { cells[i] = new TableCell(); } cells[0].Width = 50; cells[0].Controls.Add(ibtProductImage); cells[1].Text = String.Format("<h4>{0}</h4>", product.Name); cells[1].HorizontalAlign = HorizontalAlign.Left; cells[2].Text = "Цена за 1 кг.: <br>" + product.Price + " ₽"; cells[3].Text = "Вес:<br>" + cart.Amount + " кг."; cells[4].Text = "Итого:<br>" + ppw.Calc().ToString() + " ₽"; cells[5].Controls.Add(lbtDelete); var tableRow = new TableRow(); for (int i = 0; i < cells.GetLength(0); i++) { tableRow.Cells.Add(cells[i]); } table.Rows.Add(tableRow); pnlShoppingCarts.Controls.Add(table); } //Add current user's shopping cart to a specific session Session[User.Identity.GetUserId()] = purchasedList; }