Progress Telerik JustMock

Sequential Mocking

  • Sequential mocking allows you to specify different values to be returned on consecutive calls to a method.
  • 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
  • Sequential Mocking Overview

    Sequential mocking allows you to specify different values to be returned on consecutive calls to a method.

    [TestMethod]
    public void ShouldArrangeAndAssertInASequence()
    {
        // Arrange
        var foo = Mock.Create<IFoo>();
      
        Mock.Arrange(() => foo.GetIntValue()).Returns(0).InSequence();
        Mock.Arrange(() => foo.GetIntValue()).Returns(1).InSequence();
        Mock.Arrange(() => foo.GetIntValue()).Returns(2).InSequence();
      
        // Act
        int actualFirstCall = foo.GetIntValue();
        int actualSecondCall = foo.GetIntValue();
        int actualThirdCall = foo.GetIntValue();
      
        // Assert
        Assert.AreEqual(0, actualFirstCall);
        Assert.AreEqual(1, actualSecondCall);
        Assert.AreEqual(2, actualThirdCall);  
    }

    Sequential mocking documentation
Background-NextSteps

Next Steps

See Plans & Pricing

Purchase individual products or any of the bundles

Download Free Trial

With dedicated technical support.