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

Maybe this feature already exists, but I had the thought that it may be useful to be able to verify that a constructor call was made. For instance, if you were trying to validate this property in an object:

public ValuesCollection Values
if (_values == null)
_values = new ValuesCollection();
return _values;

I could then, in my test code, verify that the constructor of the ValuesCollection was called:

asked by bmains (13.2k points)

3 Answers

0 votes
Hi Brian,

Isolator AAA API does not have this feature yet - I'll suggest thios feature for future version of Isolator.
Until we'll implement it you could use the old natural/reflective API instead
answered by dhelper (11.9k points)
0 votes
Does that feature have been added since?

Or do you have an example of a solution using old natural/reflective API?

answered by pierre-luc (3.3k points)
0 votes
You can use the old API in order to do that, the concept of verify is a bit different here since you are verifying on all the recorded expectations.

For example the test below will fail since you recorded an expectation on the constructor of DummyClass but did not call it. If you'll uncomment the call to the constructor the test will pass.

public void Test()
    using (RecordExpectations r = RecorderManager.StartRecording())
        new DummyClass();
    //DummyClass dummy = new DummyClass();
answered by ohad (35.4k points)