mercredi 3 août 2016

How to make Mock

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!

Aucun commentaire:

Enregistrer un commentaire