示例#1
0
        public void Debit_QuantityBiggerThanQuantity_ThrowsException()
        {
            // Arrange
            var sut = new Product("Laptop", 1000);

            // Act
            // Assert
            Assert.Throws <ArgumentOutOfRangeException>(
                () => sut.Decrease(2000));
        }
示例#2
0
        public void Debit_ValidQuantity_DecrementQuantity()
        {
            // Arrange
            var sut      = new Product("Laptop", 1000);
            var expected = 900;

            // Act
            sut.Decrease(100);
            var actual = sut.Quantity;

            // Assert
            Assert.That(actual, Is.EqualTo(expected));
            // the same as :
            // Assert.AreEqual(expected, actual, "Check Decrease method impl");
        }
示例#3
0
        public void Debit_QuantityBiggerThanQuantity_ThrowsException_()
        {
            // Arrange
            var sut      = new Product("Laptop", 1000);
            var expected = 1000;
            var actual   = 0.0;

            // Act
            try
            {
                sut.Decrease(2000);
            }
            catch (ArgumentOutOfRangeException e)
            {
                actual = sut.Quantity;
                // Assert
                Assert.AreEqual("Quantity", e.ParamName);
                Assert.AreEqual(expected, actual);
            }
        }