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
Hi,

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?

Thanks
Steve.
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.
Steve.
answered by stephencampling (3k points)
...