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
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes
How can we make fake object of class which have parameterized constructor(No parameterless cnstructor). Also let us know how can we access private members(variables and properties) of the class for testing/verifying their values. Thanks
asked by sony (7.2k points)

4 Answers

0 votes
Hi Sony,

Good questions!

Please refer to our online help.

Faking constructors with parameters:
[url]http://docs.typemock.com/Isolator/##typemock.chm/html/M_TypeMock_ArrangeActAssert_IFaker_Instance__1_3.htm[/url]

Verifying private fields:
[url]http://docs.typemock.com/Isolator/##typemock.chm/html/M_TypeMock_ObjectState_GetField.htm[/url]

By the way, consider testing interactions instead of state, as state based testing are usually considered bad practice (Since your test code is coupled with the tested implementation details).

Good luck!

_________________
Regards

Yonatan,
TypeMock Support
answered by yonatan (1.6k points)
0 votes
Thanks very much for your invaluable and prompt response and suggestions. Also we are able to access private fields.

Can you enlighten us on accessing private properties(get/set). Thanks
answered by sony (7.2k points)
0 votes
Hi,

No problem - feel free to post on the forum, or contact our support. you can also browse our extensive documentation for info and examples:
http://docs.typemock.com/Isolator/

In order to access private properties (or other methods), you can use:

// get
var myPropertyValue = Isolate.Invoke.Method(myObject, "get_MyProperty");
//set
Isolate.Invoke.Method(myObject, "set_MyProperty", newValue);

_________________
Regards

Yonatan,
TypeMock Support
answered by yonatan (1.6k points)
0 votes
Thanks very much Yonatan.
answered by sony (7.2k points)
...