Progress Telerik JustMock

Sequential Mocking

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.

    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

Next Steps

See Plans & Pricing

Purchase individual products or any of the bundles

Download Free Trial

With dedicated technical support.