background

Telerik JustMock

Sequential Mocking

  • Sequential mocking allows you to specify different values to be returned on consecutive calls to a method.
  • Part of the fastest, most flexible and complete mocking tool for crafting unit tests.
  • Our award-winning support team is available to assist you with any issues.
Mocking and Assert Functionality
  • 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
Next Steps