ExpectConstructor doesnt work??

+1 vote
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 Nov 5, 2006 by lior (12,260 points)

5 Answers

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