background

Telerik JustMock

Fluent Mocking

  • Fluent mocking allows you to create your arrangements and assertions directly from the mock object by using extension methods.
  • 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
  • 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