chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
+1 vote

On the old TypeMock API you could mock a field with the following call;

MockObject<SqlCeConnection> connection = MockManager.MockObject<SqlCeConnection>();
connection.AssignField("_somePrivateField", connection);

Is there anyway to achieve the same result using the Isolate APIs?

asked by stephencampling (3k points)

2 Answers

0 votes
You could use the ObjectState API to do that:

var fakeConnection = Isolate.Fake.Instance<SqlCeConnection>();

ObjectState.SetField(fakeConnection, "_somePrivateField", myValue);
answered by igal (5.7k points)
0 votes
Excellent - thats worked.

Thanks for the quick response.
answered by stephencampling (3k points)