I am trying to set up a moq, but i am needing to create a fake IQueryable. i made a Collection but i am at a loss of how to cast that to an 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);
Just call AsQueryable
on your collection.
_mockRepository.Setup(x => x.GetDetail(It.IsAny<Int32>(),
It.IsAny<Enum.FeedTypeEnum.FeedType>()))
.Returns(DetailDataEntityCollection.AsQueryable());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With