AddItem() public method

public AddItem ( Item item ) : void
item Item
return void
Exemplo n.º 1
0
        public void Add_Item_To_ShoppingList()
        {
            // Arrange
            var item = new Item("item");
            var shoppingService = new ShoppingService(_sqliteConnection);

            // Act
            shoppingService.AddItem(item);

            // Assert
            Assert.Contains<Item>(shoppingService.Items, x => x == item);
        }
Exemplo n.º 2
0
        public void Remove_Item_From_ShoppingList()
        {
            // Arrange
            var item = new Item("item");
            var shoppingService = new ShoppingService(_sqliteConnection);
            shoppingService.AddItem(item);

            // Act
            shoppingService.RemoveItem(item);

            // Assert
            Assert.DoesNotContain<Item>(shoppingService.Items, x => x == item);
            Assert.Contains<BoughtItem>(shoppingService.BoughtItems, x => x.Title == item.Title);
            Assert.Contains<BoughtItem>(shoppingService.BoughtItems, x => x.Title == item.Title && x.BoughtCount == 1);
        }
Exemplo n.º 3
0
        public void TryAdd_Adds_Item_Only_If_Not_Present_On_List()
        {
            // Arrange
            var item1 = "item 1";
            var shoppingService = new ShoppingService(_sqliteConnection);
            shoppingService.AddItem(new Item(item1));

            // Act
            shoppingService.TryAddItemToShoppingList(new Item(item1));

            // Assert
            Assert.Equal(1, shoppingService.Items.Count);
        }