public async Task GetLogItemsAsync() { //PrepareTest _dishRepositoryMock.Setup(x => x.GetItemsAsync( It.IsAny <Expression <Func <ConsumedDish, bool> > >(), It.IsAny <Func <IQueryable <ConsumedDish>, IOrderedQueryable <ConsumedDish> > >(), "")) .ReturnsAsync(new List <ConsumedDish> { new ConsumedDish { Name = "Dish1" }, new ConsumedDish { Name = "Dish2" } }); _mapperMock.Setup(m => m.Map <IEnumerable <ConsumeLogItem> >(It.IsAny <List <ConsumedDish> >())) .Returns <List <ConsumedDish> >(dishes => new List <ConsumeLogItem> { new ConsumeLogItem { Food = new Food { Name = dishes[0].Name } }, new ConsumeLogItem { Food = new Food { Name = dishes[1].Name } } }); //Do test var result = await _dishService.GetLogItemsAsync(1, DateTime.Today); //Assert Assert.Equal(2, result.Count()); Assert.Equal("Dish1", result.First().Food.Name); }
public async Task <IEnumerable <ConsumeLogItem> > GetLogItems(int customerId, DateTime consumeDate) { return(await _consumedDishService.GetLogItemsAsync(customerId, consumeDate)); }