Progress Telerik JustMock

Partial Mocking

Nasa, Visa, Microsoft Fox, Samsung, IBM World Bank Group, Volvo
  • Partial Mocking Overview

    Partial mocking allows you to mock only specific members of an object while keeping the rest intact. Thus, you can continue to work with your existing, original object, not a mock object, with the benefit of being able to test your code in isolation when needed.
    [TestMethod]
    public void ShouldMockInstanceCallPartially()
    {
        // Arrange
        Foo foo = new Foo();
        // Just a single method of the original object is mocked.
        Mock.Arrange(() => foo.Echo(Arg.IsAny<int>())).Returns((int arg) => arg);
      
        // Act
        int actual = foo.Echo(10);
      
        // Assert
        Assert.AreEqual(10, actual);
    }

    Partial mocking documentation
Background-NextSteps

Next Steps

See Plans & Pricing

Purchase individual products or any of the bundles

Download Free Trial

With dedicated technical support.