How to mock an SqlDataReader using Moq – Update
Moq has an ability to run some code after the method is executed. It is called “Callback”. Modify your code this way and it will work: private IDataReader MockIDataReader() { var moq = new Mock<IDataReader>(); bool readToggle = true; moq.Setup(x => x.Read()) // Returns value of local variable ‘readToggle’ (note that // you must use … Read more