예제 #1
0
        public void AddItemsQuantityAndPriceAdded()
        {
            // Arrange
            string    pName  = "Beans";
            decimal   lPrice = 1.00M;
            int       quant  = 4;
            OrderItem beans  = new OrderItem(pName, lPrice, quant);


            // Act
            beans.AddItems(1.00M, 2);

            // Assert
            Assert.AreEqual("Beans", beans.ProductName);
            Assert.AreEqual(1.00M, beans.LatestPrice);
            Assert.AreEqual(6, beans.Quantity);
            beans.AddItems(1.00M, 2);
            Assert.AreEqual(8, beans.Quantity);
        }
예제 #2
0
        public void AddItemQuantityAddedInvalid()
        {
            // Arrange
            string    pName  = "Beans";
            decimal   lPrice = 1.00M;
            int       quant  = 4;
            OrderItem beans  = new OrderItem(pName, lPrice, quant);

            // Act
            beans.AddItems(1.00M, -1);

            // Assert
        }
예제 #3
0
        public void AddItemsTestQtyOnly()
        {
            string    prodname    = "Banana";
            decimal   latestPrice = 0.75m;
            int       quantity    = 3;
            OrderItem target      = new OrderItem(prodname, latestPrice, quantity);

            int qty      = 2;
            int actual   = target.AddItems(qty);
            int expected = 5;

            Assert.AreEqual(expected, actual);
        }
예제 #4
0
        public void AddTwoItemsTest()
        {
            // Assemble
            string    name = "Orange";
            decimal   price = 0.50m;
            int       quantity = 5, addingQuantity = 2;
            bool      expected = true, actual = false;
            OrderItem Actual = new OrderItem(name, price, quantity);

            // Act
            Actual.AddItems(addingQuantity);
            if (Actual.Quantity == quantity + addingQuantity)
            {
                actual = true;
            }
            // Assert
            Assert.AreEqual(expected, actual);
        }
예제 #5
0
        public void TotalOrderTest()
        {
            // Assemble
            string    name = "Orange";
            decimal   price = 0.50m;
            int       quantity = 5;
            bool      expected = true, actual = false;
            OrderItem Actual = new OrderItem(name, price, quantity);

            // Act
            Actual.AddItems();
            if (Actual.TotalOrder == 3.00m)
            {
                actual = true;
            }
            // Assert
            Assert.AreEqual(expected, actual);
        }