public void TestExecuteShouldReturnShoppingItems() { //arrange const string testCartId = "TestCartId"; var mockShoppingCartItemRepository = new Mock <IShoppingCartItemRepository>(); var expectedShoppingCartItems = new List <ShoppingCartItem> { _shoppingCartItems.First(), _shoppingCartItems.Last() }; mockShoppingCartItemRepository.Setup(s => s.GetAll()).Returns(_shoppingCartItems.AsQueryable); var sut = new GetShoppingCartItemsListQuery(mockShoppingCartItemRepository.Object); //act var results = sut.Execute(testCartId); //assert Assert.Equal(expectedShoppingCartItems, results); }
public void TestExecuteShouldReturnNoItemsIfNoShoppingCartIdMatchesFound() { //arrange const string testCartId = "NoMatchesId"; var mockShoppingCartItemRepository = new Mock <IShoppingCartItemRepository>(); mockShoppingCartItemRepository .Setup(s => s.GetAll()) .Returns(_shoppingCartItems.AsQueryable); var sut = new GetShoppingCartItemsListQuery(mockShoppingCartItemRepository.Object); //act var results = sut.Execute(testCartId); //assert Assert.Empty(results); }