public void ListAsyncTest1() { var mock = new Mock <IUploadFileRepository>(); mock.Setup(m => m.FindAllAsync(It.IsAny <Expression <Func <UploadFile, UploadFileViewModel> > >())) .Returns(Enumerable.Empty <UploadFileViewModel>().ToAsyncEnumerable()); var service = new UploadFileService(mock.Object); var files = service.ListAsync(); Assert.Empty(files.ToEnumerable()); }
public async Task ListAsyncTest3() { var mock = new Mock <IUploadFileRepository>(); mock.Setup(m => m.FindAllAsync(It.IsAny <Expression <Func <UploadFile, UploadFileViewModel> > >())) .Returns(Enumerable.Range(0, 10).Select(i => new UploadFileViewModel() { Id = i }).ToAsyncEnumerable()); var service = new UploadFileService(mock.Object); var files = service.ListAsync(); Assert.Equal(10, await files.CountAsync()); }