Exemplo n.º 1
0
        public void GetPrice_DiscountIsApplicablePlusOne_ShouldReturnCost()
        {
            var watch            = new Watch("001", "Rolex", 100, new Discount(3, 200));
            var watchForPurchase = new WatchForPurchase(watch, 4);

            Assert.Equal(300, watchForPurchase.GetPrice());
        }
Exemplo n.º 2
0
        public void GetPrice_DiscountNotApplicable_ShouldReturnSum()
        {
            var watch            = new Watch("001", "Rolex", 100, new Discount(3, 200));
            var watchForPurchase = new WatchForPurchase(watch, 2);

            Assert.Equal(200, watchForPurchase.GetPrice());
        }
Exemplo n.º 3
0
        public void GetPrice_NoDiscount_OneItem_ShouldReturnItemPrice()
        {
            var watch = new Watch("004", "Casio", 30);

            var watchForPurchase = new WatchForPurchase(watch, 1);

            Assert.Equal(30, watchForPurchase.GetPrice());
        }
Exemplo n.º 4
0
        public void GetPrice_NoDiscount_ThreeItems_ShouldReturnSum()
        {
            var watch = new Watch("004", "Casio", 30);

            var watchForPurchase = new WatchForPurchase(watch, 3);

            Assert.Equal(90, watchForPurchase.GetPrice());
        }
Exemplo n.º 5
0
        public void GetPrice_TwoSameWatches_GetSum()
        {
            var watch            = new Watch("004", "Casio", 30);
            var watchForPurchase = new WatchForPurchase(watch, 2);

            var cart = new Cart(new List <WatchForPurchase> {
                watchForPurchase
            });

            Assert.Equal(60, cart.GetPrice());
        }
Exemplo n.º 6
0
        public void GetPrice_ThreeWatches_GetSum()
        {
            var watch1            = new Watch("004", "Casio", 30);
            var watchForPurchase1 = new WatchForPurchase(watch1, 1);

            var watch2            = new Watch("005", "Casio", 40);
            var watchForPurchase2 = new WatchForPurchase(watch2, 1);

            var watch3            = new Watch("006", "Casio", 30);
            var watchForPurchase3 = new WatchForPurchase(watch3, 1);

            var cart = new Cart(new List <WatchForPurchase>
            {
                watchForPurchase1,
                watchForPurchase2,
                watchForPurchase3
            });

            Assert.Equal(100, cart.GetPrice());
        }
Exemplo n.º 7
0
        public async Task GetPrice_OneWatch_ShouldCallGetCartAndReturnPrice()
        {
            var ids = new List <string> {
                "001"
            };

            var watch            = new Watch("001", "Casio", 30);
            var watchForPurchase = new WatchForPurchase(watch, 1);
            var cart             = new Cart(new List <WatchForPurchase> {
                watchForPurchase
            });

            var controller = new CheckoutController(cartFactoryMock.Object);

            cartFactoryMock
            .Setup(x => x.GetCart(ids))
            .Returns(Task.FromResult(cart));

            var response = await controller.Post(ids);

            cartFactoryMock.Verify(x => x.GetCart(ids), Times.Once());

            Assert.Equal(30, response.Value.Price);
        }