Progress Telerik JustMock

Fluent Mocking

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

    There are many ways in which you can set up your test arrangements and assert your test expectations. Fluent mocking allows you to create your arrangements and assertions directly from the mock object by using extension methods. Some developers find this approach to writing code faster and more convenient.

    IFileReader fileReader = Mock.Create<IFileReader>();
    const string expected = @"C:\JustMock";
    // Arrange
    Mock.Arrange(()=> fileReader.Path ).Returns(expected).OccursOnce(); // explicit arrange
    fileReader.Arrange(x => x.Path).Returns(expected).OccursOnce(); // fluent arrange
    // Act
    var actual = fileReader.Path;
    // Assert
    Assert.AreEqual( expected, actual ); // explicit assert
    fileReader.Assert( x => x.Path ); // fluent assert

    Fluent mocking documentation

Next Steps

See Plans & Pricing

Purchase individual products or any of the bundles

Download Free Trial

With dedicated technical support.