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
0 votes

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

3 Answers

0 votes
You can't - I'll add a feature request to our backlog
answered by dhelper (11.9k points)
0 votes
not even with older API?
answered by error (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>();

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

Using Natural Mocks:
using(var recorder =RecorderManager.StartRecording())
    Dummy recorded = new Dummy(0);

var d = new Dummy(5);

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