And*_*ndy 4 c# linq collections
我正在尝试设置一个moq,但我需要创建一个假的IQueryable.我做了一个收藏,但我不知道如何把它投入到IQueryable.
Collection<DetailDataEntity> DetailDataEntityCollection =
new Collection<DetailDataEntity>();
DetailDataEntity DetailDataEntity = new DetailDataEntity();
DetailDataEntity.FeedTypeID = 1;
DetailDataEntityCollection.Add(DetailDataEntity);
_mockRepository.Setup(x => x.GetDetail(It.IsAny<Int32>(),
It.IsAny<Enum.FeedTypeEnum.FeedType>()))
.Returns(DetailDataEntityCollection);
Run Code Online (Sandbox Code Playgroud)
只需打电话AsQueryable给你的收藏.
_mockRepository.Setup(x => x.GetDetail(It.IsAny<Int32>(),
It.IsAny<Enum.FeedTypeEnum.FeedType>()))
.Returns(DetailDataEntityCollection.AsQueryable());
Run Code Online (Sandbox Code Playgroud)