Exemplo n.º 1
0
        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");
        }
Exemplo n.º 2
0
        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");
        }
Exemplo n.º 4
0
        public decimal ValueProducts(IEnumerable <Product> products)
        {
            decimal productsSum      = products.Sum(p => p.Price);
            decimal productsDiscount = discounter.ApplyDiscount(productsSum);

            return(productsDiscount);
        }
Exemplo n.º 5
0
        public void Discount_Negative_Total()
        {//arrange
            IDiscountHelper target = getTestObject();

            // act
            target.ApplyDiscount(-1);
        }
Exemplo n.º 6
0
 public decimal ValueProducts(IEnumerable <Product> products)
 {
     if (products == null)
     {
         return(0m);
     }
     return(discounter.ApplyDiscount(products.Sum(x => x.Price)));
 }
Exemplo n.º 7
0
        public void Dicsount_Negative_Total()
        {
            // Arrange (시나리오를 설정한다.)
            IDiscountHelper target = getTestObject();

            // Act (작업을 시도한다.)
            target.ApplyDiscount(-1);
        }
Exemplo n.º 8
0
        public void Discount_Above_100()
        {
            IDiscountHelper target          = getTestObject();
            decimal         total           = 200;
            var             discountedTotal = target.ApplyDiscount(total);

            Assert.AreEqual(total * 0.9M, discountedTotal);
        }
Exemplo n.º 9
0
        public void Discount_Negative_Total()
        {
            // przygotowanie
            IDiscountHelper target = getTestObject();

            // działanie
            target.ApplyDiscount(-1);
        }
Exemplo n.º 10
0
        public void Discount_Negative_Total()
        {
            // arrange (организация)
            IDiscountHelper target = getTestObject();

            // act (акт)
            target.ApplyDiscount(-1);
        }
Exemplo n.º 11
0
        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);
        }
Exemplo n.º 12
0
        public void Discount_Negative_Total()
        {
            // 准备
            IDiscountHelper target = getTestObject();

            // 动作
            target.ApplyDiscount(-1);
        }
Exemplo n.º 13
0
        public void Discount_Above_Negative_Total()
        {
            // Arrage - 시나리오 설정
            IDiscountHelper target = getTestOjbect();

            // Act - 작업 시도
            target.ApplyDiscount(-1);
        }
Exemplo n.º 14
0
        /// <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);
        }
Exemplo n.º 15
0
        [ExpectedException(typeof(ArgumentOutOfRangeException))] //assert
        public void NegativeTotalsNotAllowed()
        {
            //arrange
            IDiscountHelper target = getTestObject();

            //act
            target.ApplyDiscount(-1);
        }
Exemplo n.º 16
0
        [ExpectedException(typeof(ArgumentOutOfRangeException))]//утверждение, которое будет выполнено только в том случае, если модульный тест выбросит исключение типа, указанного параметром ExceptionType.Это аккуратный способ ловить исключения без необходимости возиться с блоками try...catch в юнит тесте.
        public void Discount_Negative_Total()
        {
            //ARRANGE
            IDiscountHelper target = getTestObject();

            //ACT
            target.ApplyDiscount(-1);
            //ASSERT
        }
Exemplo n.º 17
0
        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);
        }
Exemplo n.º 18
0
        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);
        }
Exemplo n.º 19
0
        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);
        }
Exemplo n.º 20
0
        [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% от первоначальной общей стоимости
        }
Exemplo n.º 21
0
        public void TestMethod1()
        {
            //Arrange
            IDiscountHelper taget = getTestOBJ();
            Decimal         total = 200;
            //act
            var discountTotal = taget.ApplyDiscount(total);

            //assert
            Assert.AreEqual(total * 0.9M, discountTotal);
        }
Exemplo n.º 22
0
        public void Ten_Percent_Default_Discount()
        {
            // arrange
            IDiscountHelper target = getTestObject();
            decimal         total  = 200;
            // act
            var discountedTotal = target.ApplyDiscount(total);

            // assert
            Assert.AreEqual(180, discountedTotal);
        }
Exemplo n.º 23
0
        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);
        }
Exemplo n.º 24
0
        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");
        }
Exemplo n.º 25
0
        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);
        }
Exemplo n.º 26
0
        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);
        }
Exemplo n.º 27
0
        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);
        }
Exemplo n.º 28
0
        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);
        }
Exemplo n.º 30
0
        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");
        }