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
Hi,
I want to create a small test that checks that Class A in his constructor create an object of class B. for this I am using on the mocked class the ExpectConstructor() method and for some reason the test passes even i no call the to the constructor is made.

what am I doing wrong? (or is this a bug?)

here is a sample code:

    public class B
    {    }
    public class A
    {
        public A()
        {
            //here there should be a call to create an object of class B
        }
    }

        [TestMethod()]
        public void ctorTest()
        {
            MockManager.Init();
            Mock b = MockManager.Mock(typeof(B));
            b.ExpectConstructor();

            A target = new A();

            MockManager.Verify(); 
        }
asked by lior (13.2k points)

5 Answers

0 votes
Hi
This is a known bug.
The fix will be in available in our next release.
I will send you the patch offline as soon as it will be ready.
answered by ohad (35.4k points)
0 votes
thank you
answered by lior (13.2k points)
0 votes
Any estimated target date for this fix?
answered by lior (13.2k points)
0 votes
Hi,
I must first correct, this is not a BUG. This is a feature that we have not implemented yet.
Currently ExpectConstructor is used to validate constructor arguments.

We do have plans to expand the features of the constructors to support:
:arrow: chained constructors (one constructor calling another),
:arrow: verifying that a constructor was actually called
and more.
This should be implemented in our next release that will be out in the beginning of next year.

If you wish, we will send you a preview, once the feature is complete.
answered by scott (32k points)
0 votes
Hi Lior
A patch was created and sent.
answered by ohad (35.4k points)
...