How to make Mock<IDataReader> have field count?
<p>I am using moq to test C# code. The tested method has a passed in IDataReader as argument. I used Mock to mock the data reader by setup the key and value for each field (redare.Setup(x => x["fieldName"]).Returns(value)). However, we also have a method called in the tested method. The called method is testing if the field that reader is reading does exist. I found the Mocked reader doesn't have any field counted when the mocked reader casted to IDataReader by using Mocked reader.Object. Can anybody help me how to set up field counting/field name in Mock? Thanks a lot!  </p>

<p>Update:
I used this post solving my issue. Thanks for any response.
<a href="https://stackoverflow.com/questions/35200882/how-to-mock-idatareader-to-test-method-which-converts-sqldatareader-to-system-da">How to mock IDataReader to test method which converts SqlDataReader to System.DataView</a></p>