public void ItemsEngine_GetAllItems() { //Arrange: Seeds the Mocked Accessor's list of Items and creates the expected list of Items SeedItems(); var expected = new List <Item> { new Item { Id = 1, Name = "Candy", GroceryListId = 1 }, new Item { Id = 2, Name = "Juice", GroceryListId = 1 }, new Item { Id = 3, Name = "Trash Bags", GroceryListId = 2 } }; //Act: Calls the ItemsEngine GetAllItems() method which returns a list of all items var result = itemsEngine.GetAllItems().ToList(); //Assert: Checks whether the expected and result lists are the exact same for (int i = 0; i < result.Count; i++) { Assert.AreEqual(expected.ElementAt(i), result.ElementAt(i), $"The Item at index {i} was retrieved incorrectly."); } }
public IEnumerable <Item> GetAllItems() { return(_itemsEngine.GetAllItems().ToArray()); }