I\'m new to moq and setting up mocks so i could do with a little help. How do I mock up an SqlDataReader using Moq?
Update
After further testing this is what I h
After some testing the problem is trying to set the DataReader.Read() to true for one loop and then setting it to false. Rhino Mock has the Repeat.Once() option but I could not find a similar method in Moq (I might be wrong here).
The main reason for testing this was the extension methods to convert the reader to the relevant datatype so in the end I removed the while loop and just accessed the values that had been setup in my mock. The code looks as follows:
private IDataReader MockIDataReader()
{
var moq = new Mock();
moq.SetupGet
Not an ideal solution but it works. If anyone knows better leave a comment thanks.