Ejemplo n.º 1
0
 public void AddItem_ShouldReturnTotalPriceOfItemsInTheCart()
 {
     //Arrange
     var shoppingCart = new ShoppingCart();
     //Act
     shoppingCart.AddItem(StubCartItem(Tests.FAKE_JEWELRY_REPOSITORY_FIRST_ITEM_ID,1000,CartItemType.Jewelry));
     shoppingCart.AddItem(StubCartItem(1112,3000,CartItemType.Jewelry));
     //Assert
     shoppingCart.TotalPrice.Should().Be(1000 + 3000);
 }
Ejemplo n.º 2
0
        public void Count_ShouldReturnTheRightItemCount()
        {
            //Arrange
            var shoppingCart = new ShoppingCart();
            //Act
            shoppingCart.AddItem(StubCartItem(Tests.FAKE_JEWELRY_REPOSITORY_FIRST_ITEM_ID, 1000, CartItemType.Jewelry));
            shoppingCart.AddItem(StubCartItem(1112, 3000, CartItemType.Jewelry));

            var totalItems = shoppingCart.Count;

            //Assert
            totalItems.Should().Be(2);
        }
Ejemplo n.º 3
0
 public void AddItem_ShouldAddAnItemToTheCartItemsList()
 {
     //Arrange
     var shoppingCart = new ShoppingCart();
     //Act
     shoppingCart.AddItem(StubCartItem(Tests.FAKE_JEWELRY_REPOSITORY_FIRST_ITEM_ID,1234,CartItemType.Jewelry));
     //Assert
     shoppingCart.Items.Should().HaveCount(1);
 }
Ejemplo n.º 4
0
        public void Remove_ShouldRemoveAnItemByCartID()
        {
            //Arrange
            var shoppingCart = new ShoppingCart();
            //Act
            shoppingCart.AddItem(StubCartItem(Tests.FAKE_JEWELRY_REPOSITORY_FIRST_ITEM_ID, 1000, CartItemType.Jewelry));
            shoppingCart.AddItem(StubCartItem(1112, 3000, CartItemType.Jewelry));

            shoppingCart.Remove(1);

            //Assert
            shoppingCart.Items.Should().HaveCount(1);
        }
Ejemplo n.º 5
0
        public void Update_ShouldUpdateAnItem()
        {
            //Arrange
            var shoppingCart = new ShoppingCart();
            shoppingCart.AddItem(FakeJewelCartItem(Tests.NUMBER_HAS_NO_MEANING_IN_THIS_CONTEXT, Tests.SAMPLE_JEWEL_SIZE_725,
                                                   Tests.MEDIA_TYPE_IS_NOT_IMPORANT,
                                                   Tests.NUMBER_HAS_NO_MEANING_IN_THIS_CONTEXT));

            var updatedCartItem = FakeJewelCartItem(Tests.NUMBER_HAS_NO_MEANING_IN_THIS_CONTEXT, "11.25",
                                                    Tests.MEDIA_TYPE_IS_NOT_IMPORANT,
                                                    Tests.NUMBER_HAS_NO_MEANING_IN_THIS_CONTEXT);
            //Act

            shoppingCart.Update(0, updatedCartItem);

            //Assert
            var finalItem = shoppingCart.Items[0] as JewelCartItem;
            finalItem.Size.Should().Be("11.25");
        }
Ejemplo n.º 6
0
        public void Remove_ShouldRemoveAnItemByCartIDAndRecalcualtePrice()
        {
            //Arrange
            var shoppingCart = new ShoppingCart();
            //Act
            shoppingCart.AddItem(StubCartItem(Tests.FAKE_JEWELRY_REPOSITORY_FIRST_ITEM_ID, 1000, CartItemType.Jewelry));
            shoppingCart.AddItem(StubCartItem(1112, 3000, CartItemType.Jewelry));

            shoppingCart.Remove(1);

            //Assert
            shoppingCart.TotalPrice.Should().Be(4000-3000);
        }