Progress Telerik JustMock

Recursive Mocking

  • Recursive mocking is a productivity feature that enables you to mock a chained call to a member.
  • This feature is a part of the fastest, most flexible and complete mocking tool for crafting unit tests.
  • Our award-winning support team is dedicated to assisting you with any questions and issues you may have during your application development.
Mocking and Assert Functionality
Nasa, Visa, Microsoft Fox, Samsung, IBM World Bank Group, Volvo
  • Recursive Mocking Overview

    Recursive mocking is a productivity feature that allows you to mock a chained call to a member. This saves you the effort to create new objects, associating them to members, and executing additional logic for the "chain" to be fully prepared for access.

    [TestMethod]
    public void ShouldAssertNestedPropertyGet()
    {
        var expected = 10;
     
        // ARRANGE
        // Creating a mocked instance of the "IFoo" interface.
        var foo = Mock.Create<IFoo>();
     
        // Arranging: When foo.Bar.Value is called, it should return expected value.
        //              This will automatically create mock of foo.Bar
        //              and a NullReferenceException will be avoided.
        Mock.Arrange(() => foo.Bar.Value).Returns(expected);
     
        // ACT
        var actual = foo.Bar.Value;
     
        // ASSERT
        Assert.AreEqual(expected, actual);
    }

    Recursive mocking documentation
Background-NextSteps

Next Steps

See Plans & Pricing

Purchase individual products or any of the bundles

Download Free Trial

With dedicated technical support.