Invoking the constructor of a mocked object

2 posts, 0 answers
  1. Asim
    Asim avatar
    7 posts
    Member since:
    Jul 2011

    Posted 28 Jul 2011 Link to this post

    Hi!

    Does JustMock allow invoking the actual constructor of the mocked object, and passing it certain argument values, similar to how TypeMock does (please see TypeMock documentation link below)?

    http://docs.typemock.com/Isolator/##typemock.chm/Documentation/ConstructorArgumentsAAA.html

    Thanks,
    Asim
  2. Ricky
    Admin
    Ricky avatar
    467 posts

    Posted 29 Jul 2011 Link to this post

    Hi Asim,

    Thanks again for pointing that to us. For JustMock you don’t have to specify explicitly that constructor shouldn’t be mocked rather by default the behavior is that it invokes the original (Like Moq).

    [TestMethod]
    public void PassArgumentsToConstructor_FakeMethods()
    {
        var fake = Mock.Create<Person>(x => new Person(100));
        Assert.AreEqual(100, fake.Age);
    }

    However there is a point in the documentation on how you can mock the constructor, even if you don’t pass the instance via dependency Injection. For that i am creating a task and giving you some telerik points for it as well :-).
     
    Here is the task for you to monitor:
    http://www.telerik.com/support/pits.aspx#/public/justmock/7167

    Kind Regards,
    Mehfuz
    the Telerik team

     

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  3. DevCraft R3 2016 release webinar banner
Back to Top