public void Discount_Between_10_And_100() { //准备 arrange IDiscountHelper target = getTestObject(); //动作 act decimal TenDollarDiscount = target.ApplyDiscount(10); decimal HundredDollarDiscount = target.ApplyDiscount(100); decimal FiftyDollarDiscount = target.ApplyDiscount(50); //断言 Assert.AreEqual(5, TenDollarDiscount, "$10 discount is wrong"); Assert.AreEqual(95, HundredDollarDiscount, "$100 discount is wrong"); Assert.AreEqual(45, FiftyDollarDiscount, "$50 discount is wrong"); }
public void Discount_Between_10_And_100() { // arrange (организация) IDiscountHelper target = getTestObject(); // act (акт) decimal TenDollarDiscount = target.ApplyDiscount(10); decimal HundredDollarDiscount = target.ApplyDiscount(100); decimal FiftyDollarDiscount = target.ApplyDiscount(50); // assert (утверждение) Assert.AreEqual(5, TenDollarDiscount, "$10 разница"); Assert.AreEqual(95, HundredDollarDiscount, "$100 разница"); Assert.AreEqual(45, FiftyDollarDiscount, "$50 разница"); }
public void Discount_Between_10_And_100() { // Arange IDiscountHelper target = GetTestObject(); // Act decimal tenDollorDiscount = target.ApplyDiscount(10); decimal hundredDollorDiscount = target.ApplyDiscount(100); decimal fiftyDollorDiscount = target.ApplyDiscount(50); // Assert Assert.AreEqual(5, tenDollorDiscount, "$10 discount is wrong"); Assert.AreEqual(95, hundredDollorDiscount, "$100 discount is wrong"); Assert.AreEqual(45, fiftyDollorDiscount, "$50 discount is wrong"); }
public decimal ValueProducts(IEnumerable <Product> products) { decimal productsSum = products.Sum(p => p.Price); decimal productsDiscount = discounter.ApplyDiscount(productsSum); return(productsDiscount); }
public void Discount_Negative_Total() {//arrange IDiscountHelper target = getTestObject(); // act target.ApplyDiscount(-1); }
public decimal ValueProducts(IEnumerable <Product> products) { if (products == null) { return(0m); } return(discounter.ApplyDiscount(products.Sum(x => x.Price))); }
public void Dicsount_Negative_Total() { // Arrange (시나리오를 설정한다.) IDiscountHelper target = getTestObject(); // Act (작업을 시도한다.) target.ApplyDiscount(-1); }
public void Discount_Above_100() { IDiscountHelper target = getTestObject(); decimal total = 200; var discountedTotal = target.ApplyDiscount(total); Assert.AreEqual(total * 0.9M, discountedTotal); }
public void Discount_Negative_Total() { // przygotowanie IDiscountHelper target = getTestObject(); // działanie target.ApplyDiscount(-1); }
public void Discount_Negative_Total() { // arrange (организация) IDiscountHelper target = getTestObject(); // act (акт) target.ApplyDiscount(-1); }
Discount_Less_Than_10() { //arrange IDiscountHelper target = getTestObject(); // act decimal discount5 = target.ApplyDiscount(5); decimal discount0 = target.ApplyDiscount(0); // assert Assert .AreEqual(5, discount5); Assert .AreEqual(0, discount0); }
public void Discount_Negative_Total() { // 准备 IDiscountHelper target = getTestObject(); // 动作 target.ApplyDiscount(-1); }
public void Discount_Above_Negative_Total() { // Arrage - 시나리오 설정 IDiscountHelper target = getTestOjbect(); // Act - 작업 시도 target.ApplyDiscount(-1); }
/// <summary> /// Calculate Product Price with Discount applied /// </summary> /// <param name="products">Product list</param> /// <returns>Total product after discount applied</returns> public decimal ValueProducts(IEnumerable <Product> products) { var totalProducts = products.Sum(p => p.Price); // Apply discount here var discount = _discounter.ApplyDiscount(totalProducts); return(totalProducts - discount); }
[ExpectedException(typeof(ArgumentOutOfRangeException))] //assert public void NegativeTotalsNotAllowed() { //arrange IDiscountHelper target = getTestObject(); //act target.ApplyDiscount(-1); }
[ExpectedException(typeof(ArgumentOutOfRangeException))]//утверждение, которое будет выполнено только в том случае, если модульный тест выбросит исключение типа, указанного параметром ExceptionType.Это аккуратный способ ловить исключения без необходимости возиться с блоками try...catch в юнит тесте. public void Discount_Negative_Total() { //ARRANGE IDiscountHelper target = getTestObject(); //ACT target.ApplyDiscount(-1); //ASSERT }
public void DiscountIs5DollarsBetween10And100() { //arrange IDiscountHelper target = this.getTestObject(); decimal total1 = 100; //high end edge case decimal total2 = 55; //middle decimal total3 = 10; //low end edge case //act var withDiscount1 = target.ApplyDiscount(total1); var withDiscount2 = target.ApplyDiscount(total2); var withDiscount3 = target.ApplyDiscount(total3); //assert Assert.AreEqual(total1 - 5M, withDiscount1); Assert.AreEqual(total2 - 5M, withDiscount2); Assert.AreEqual(total3 - 5M, withDiscount3); }
public void Discount_Above_100() {// arranged , get test object IDiscountHelper target = getTestObject(); decimal total = 200; // action var discountedTotal = target.ApplyDiscount(total); // assert Assert.AreEqual(total * 0.9M, discountedTotal); }
public void Discount_Above_100() { // Arrange IDiscountHelper target = getTestObject(); decimal total = 200; // Act var discountTotal = target.ApplyDiscount(total); // Assert Assert.AreEqual(total * 0.9M, discountTotal); }
[TestMethod]//отдельными юнит тестами являются методы public void Discount_Above_100() { // PART ARRANGE !!! IDiscountHelper target = getTestObject(); //getTestObject создает экземпляр объекта который собираемся тестировать:MinimumDiscountHelper decimal total = 200; // PART ACT!!! вызываем метод MinimumDiscountHelper.ApplyDiscount и присваиваем результат переменной discountedTotal var discountedTotal = target.ApplyDiscount(total); // PART ASSERT !!! Assert.AreEqual(total * 0.9M, discountedTotal);//метод Assert.AreEqual, для проверки, значения, которые мы получили от метода ApplyDiscount, составляет 90% от первоначальной общей стоимости }
public void TestMethod1() { //Arrange IDiscountHelper taget = getTestOBJ(); Decimal total = 200; //act var discountTotal = taget.ApplyDiscount(total); //assert Assert.AreEqual(total * 0.9M, discountTotal); }
public void Ten_Percent_Default_Discount() { // arrange IDiscountHelper target = getTestObject(); decimal total = 200; // act var discountedTotal = target.ApplyDiscount(total); // assert Assert.AreEqual(180, discountedTotal); }
public void Discount_Above_100() { // arrange - instance of the object being tested is created IDiscountHelper target = getTestObject(); decimal total = 200; // act var discountedTotal = target.ApplyDiscount(total); // assert - throws an exception if the check fails; all assertions have to succeed for the unit test to pass Assert.AreEqual(total * 0.9M, discountedTotal); }
public void Discount_Above_100() { // arrange IDiscountHelper target = getTestObject(); decimal total = 200; // act var discountedTotal = target.ApplyDiscount(total); // assert Assert.AreEqual(total * 0.9m, discountedTotal, "These are not equal"); }
public void Discount_Above_100() { // arrange IDiscountHelper target = this.getTestObject(); decimal total = 200; // act decimal discountedTotal = target.ApplyDiscount(total); // assert Assert.AreEqual(total * 0.9M, discountedTotal); }
public void Dicsount_Above_100() { // Arrange (시나리오를 설정한다.) IDiscountHelper target = getTestObject(); decimal total = 200; // Act (작업을 시도한다.) var discountedTotal = target.ApplyDiscount(total); // Assert(결과를 검증한다.) Assert.AreEqual(total * 0.9M, discountedTotal); }
public void Discount_Above_100() { // arrange (организация) IDiscountHelper target = getTestObject(); decimal total = 200; // act (акт) var discountedTotal = target.ApplyDiscount(total); // assert (утверждение) Assert.AreEqual(total * 0.9M, discountedTotal); }
public void DiscountIs10PercentOver100() //discount should be 10% { //arrange IDiscountHelper target = this.getTestObject(); decimal total = 200; //act var discountedTotal = target.ApplyDiscount(total); //assert Assert.AreEqual(total * 0.9M, discountedTotal); }
public void ApplyDiscount_PriceAbove100_Discount10Perc() { // Assert IDiscountHelper discountHelper = GetTestObject(); decimal price = 200; // Act var discountedPrice = discountHelper.ApplyDiscount(price); // Assert Assert.AreEqual(180, discountedPrice); }
public void Discount_Above_100() { // arrange IDiscountHelper target = getTestObject(); decimal total = 200; // act var discountedTotal = target.ApplyDiscount(total); // assert Assert.AreEqual(total * 0.9M, discountedTotal, ">$100 discount is wrong"); }