示例#1
0
        public void Remove_Item_From_ShoppingList_That_Is_Present_On_BoughtList()
        {
            // Arrange
            var itemTitle       = "item";
            var item            = new Item(itemTitle);
            var shoppingService = new ShoppingService(_sqliteConnection);

            shoppingService.AddItem(item);
            shoppingService.AddToBoughtItems(item);

            // Act
            shoppingService.RemoveItem(item);

            // Assert
            Assert.DoesNotContain <Item>(shoppingService.Items, x => x == item);
            Assert.Contains <BoughtItem>(shoppingService.BoughtItems, x => x.Title == item.Title && x.BoughtCount == 2);
        }
示例#2
0
        public void BoughtItems_Are_Always_Sorted_By_BoughtCount()
        {
            // Arrange
            var item1           = "item 1";
            var item2           = "item 2";
            var item3           = "item 3";
            var shoppingService = new ShoppingService(_sqliteConnection);

            // Act
            shoppingService.AddToBoughtItems(new Item(item1));
            shoppingService.AddToBoughtItems(new Item(item1));
            shoppingService.AddToBoughtItems(new Item(item2));
            shoppingService.AddToBoughtItems(new Item(item3));
            shoppingService.AddToBoughtItems(new Item(item3));
            shoppingService.AddToBoughtItems(new Item(item3));

            // Assert
            var expected = shoppingService.BoughtItems.OrderByDescending(x => x.BoughtCount);

            Assert.Equal(expected, shoppingService.BoughtItems);
        }