I am using nj4x and it has a class that has readonly fields as follows.
public class MarketInformation
{
public readonly double ASK;
public readonly double BID;
public readonly double DIGITS;
public readonly double EXPIRATION;
public readonly double FREEZELEVEL;
}
I am writing unit tests for classes and methods writing these classes. For isolation/ mocking I am using Nsubstitute and MicrosoftFakes (shims mainly). I want to override these fields so when they are called in my methods I get predictable results for testing. I generated shim for this class but all it provides me is a constructor, now allowing me to initialize it still. Is there any way to set these fields from outside this class?
You'll probably need to create a wrapper class with your own
get
properties to stub or shim it out. You could create your own interface if you wanted to use stubs (not shown).