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 Answers. Here you can ask and receive answers from other community members. And if you liked or disliked an answer or thread: react with an up- or downvote Enjoy!
0 votes
Hi,

How can I verify that a specific constructor was invoked during a test?
asked by (6.6k points)

3 Answers

0 votes
You can't - I'll add a feature request to our backlog
answered by (11.9k points)
0 votes
not even with older API?
answered by (6.6k points)
0 votes
The older API do have a way to verify that a specific c'tor was called

Using Reflective Mocks:
Mock mock = MockManager.Mock<Dummy>();
mock.ExpectConstructor().Args(Check.IsTypeOf(typeof(int)));

Dummy d = new Dummy(1.2);
MockManager.Verify();// fail


Using Natural Mocks:
using(var recorder =RecorderManager.StartRecording())
{
    Dummy recorded = new Dummy(0);
    recorder.CheckArguments(Check.IsTypeOf(typeof(int)));
}

var d = new Dummy(5);

MockManager.Verify(); // pass
answered by (11.9k points)
...