public void DoDiscountCategoryDiscountValueTest(double price, int discountValue, Category discountCategory, Category productCategory) { var product = new Product() { BasePrice = price, ResultPrice = price, Type = productCategory }; var discount = new CertificateDiscount() { DiscountValue = discountValue, CategoryOfProduct = discountCategory }; discount.DoDiscount(product); if (discount.CategoryOfProduct != product.Type && discount.CategoryOfProduct != Category.All) { Assert.That(() => discount.DiscountValue, Is.EqualTo(discountValue)); } }
private void randomButton_Click(object sender, EventArgs e) { switch (Project.Rnd.Next(2)) { case 0: var percentDiscount = new PercentDiscount() { CategoryOfProduct = (Category)Project.Rnd.Next(4), DiscountValue = Project.Rnd.Next(101) }; iDiscountBindingSource.Add(percentDiscount); WriteDiscountInfo(percentDiscount, iDiscountBindingSource.Count - 1); break; case 1: var certificateDiscount = new CertificateDiscount() { CategoryOfProduct = (Category)Project.Rnd.Next(4), DiscountValue = Project.Rnd.Next(100000) }; iDiscountBindingSource.Add(certificateDiscount); WriteDiscountInfo(certificateDiscount, iDiscountBindingSource.Count - 1); break; } discountListDataGridView.Update(); }
public void NegativeDiscountValueTest(int value) { var discount = new CertificateDiscount(); Assert.That(() => discount.DiscountValue = value, Throws.Exception.TypeOf <ArgumentOutOfRangeException>()); }
public void PositiveDiscountValueTest(int value) { var discount = new CertificateDiscount(); Assert.That(() => discount.DiscountValue = value, Is.EqualTo(value)); }