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!

ExpectConstructor doesnt work??

+1 vote
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

        public void ctorTest()
            Mock b = MockManager.Mock(typeof(B));

            A target = new A();

asked Nov 5, 2006 by lior (18,340 points)

5 Answers

+1 vote
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 Nov 5, 2006 by ohad (37,060 points)
+1 vote
thank you
answered Nov 7, 2006 by lior (18,340 points)
+1 vote
Any estimated target date for this fix?
answered Nov 26, 2006 by lior (18,340 points)
0 votes
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 Nov 27, 2006 by scott (29,040 points)
+1 vote
Hi Lior
A patch was created and sent.
answered Dec 12, 2006 by ohad (37,060 points)