skip navigation
  • Product Bundles

    DevCraft

    All Telerik .NET tools and Kendo UI JavaScript components in one package. Now enhanced with:

    • NEW: Design Kits for Figma
    • Online Training
    • Document Processing Library
    • Embedded Reporting for web and desktop

    Web

    Kendo UI UI for Angular UI for Vue UI for jQuery KendoReact UI for Blazor UI for ASP.NET Core UI for ASP.NET MVC UI for ASP.NET AJAX

    Mobile

    UI for .NET MAUI

    Document Management

    Telerik Document Processing

    Desktop

    UI for .NET MAUI UI for WinUI UI for WinForms UI for WPF

    Reporting

    Telerik Reporting Telerik Report Server

    Testing & Mocking

    Test Studio Telerik JustMock

    CMS

    Sitefinity

    AI Productivity Tools

    AI Coding Assistants

    UI/UX Tools

    ThemeBuilder Design System Kit Templates and Building Blocks

    Debugging

    Fiddler Fiddler Everywhere Fiddler Classic Fiddler Everywhere Reporter FiddlerCore

    Free Tools

    KendoReact Free VB.NET to C# Converter Testing Framework
    View all products
  • Overview
    • What's New
    • Roadmap
    • Release History
  • Docs & Support
  • Pricing
  • Shopping cart
    • Account Overview
    • Your Licenses
    • Downloads
    • Support Center
    • Forum Profile
    • Payment Methods
    • Edit Profile
    • Log out
  • Login
  • Contact Us
  • Try now

Class FluentHelper

Contains fluent extensions for setting up or asserting mock expectations.

Inheritance
System.Object
FluentHelper
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: Telerik.JustMock.Helpers
Assembly: Telerik.JustMock.dll

Syntax

public static class FluentHelper

Methods

Arrange<T>(T, Expression<Action<T>>)

Setups the target call to act in a specific way.

Declaration
public static ActionExpectation Arrange<T>(this T obj, Expression<Action<T>> expression)
Parameters
T obj

Target instance.

System.Linq.Expressions.Expression<System.Action<T>> expression

Target expression.

Returns
ActionExpectation

Reference to ActionExpectation to setup the mock.

Type Parameters
T

Return type for the target setup.

Arrange<T, TResult>(T, Expression<Func<T, TResult>>)

Setups the target call to act in a specific way.

Declaration
public static FuncExpectation<TResult> Arrange<T, TResult>(this T obj, Expression<Func<T, TResult>> expression)
Parameters
T obj

Target instance.

System.Linq.Expressions.Expression<System.Func<T, TResult>> expression

Target expression.

Returns
FuncExpectation<TResult>

Reference to FuncExpectation<TReturn> to setup the mock.

Type Parameters
T

Mock type

TResult

Return type for the target setup.

ArrangeLike<T>(T, Expression<Func<T, Boolean>>)

Arranges the return values of properties and methods according to the given functional specification.

Declaration
public static void ArrangeLike<T>(this T mock, Expression<Func<T, bool>> functionalSpecification)
Parameters
T mock

The mock on which to make the arrangements.

System.Linq.Expressions.Expression<System.Func<T, System.Boolean>> functionalSpecification

The functional specification to apply to this mock.

Type Parameters
T

Type of the mock.

Remarks

See article "Create Mocks By Example" for further information on how to write functional specifications.

ArrangeSet<T>(T, Action<T>)

Setups target property set operation to act in a specific way.

Declaration
public static ActionExpectation ArrangeSet<T>(this T obj, Action<T> action)
Parameters
T obj

Target mock object

System.Action<T> action

Propery set action

Returns
ActionExpectation

Reference to ActionExpectation to setup the mock.

Type Parameters
T

Mock type

Assert<T>(T, Expression<Action<T>>, String)

Asserts the specific call

Declaration
public static void Assert<T>(this T obj, Expression<Action<T>> action, string message = null)
Parameters
T obj

Target object.

System.Linq.Expressions.Expression<System.Action<T>> action

Target action.

System.String message

Type Parameters
T

Type of the mock.

Assert<T>(T, Expression<Action<T>>, Occurs, String)

Asserts the specific call

Declaration
public static void Assert<T>(this T obj, Expression<Action<T>> expression, Occurs occurs, string message = null)
Parameters
T obj

Target mock object

System.Linq.Expressions.Expression<System.Action<T>> expression

Target expression

Occurs occurs

Specifies the number of times a mock call should occur.

System.String message

Type Parameters
T

Type of the mock.

Assert<T>(T, String)

Asserts all expected calls that are marked as must or to be occurred a certain number of times.

Declaration
public static void Assert<T>(this T target, string message = null)
Parameters
T target

Target instance.

System.String message

Type Parameters
T

Type of the mock.

Assert<T, TReturn>(T, Expression<Func<T, TReturn>>, String)

Asserts the specific call

Declaration
public static void Assert<T, TReturn>(this T obj, Expression<Func<T, TReturn>> action, string message = null)
Parameters
T obj

Target object.

System.Linq.Expressions.Expression<System.Func<T, TReturn>> action

Target action.

System.String message

Type Parameters
T

Type of the mock.

TReturn

Return type for the target setup.

Assert<T, TReturn>(T, Expression<Func<T, TReturn>>, Occurs, String)

Asserts the specific call

Declaration
public static void Assert<T, TReturn>(this T obj, Expression<Func<T, TReturn>> expression, Occurs occurs, string message = null)
Parameters
T obj

Target object.

System.Linq.Expressions.Expression<System.Func<T, TReturn>> expression

Target expression

Occurs occurs

Specifies the number of times a mock call should occur.

System.String message

Type Parameters
T

Type of the mock.

TReturn

Return type for the target setup.

AssertAll<T>(T, String)

Asserts all expected setups.

Declaration
public static void AssertAll<T>(this T target, string message = null)
Parameters
T target

Target instance.

System.String message

Type Parameters
T

Type of the mock.

AssertSet<T>(T, Action<T>, String)

Asserts the specific call

Declaration
public static void AssertSet<T>(this T obj, Action<T> action, string message = null)
Parameters
T obj

Target mock object

System.Action<T> action

Propert set action

System.String message

A message to display if the assertion fails.

Type Parameters
T

Type of the mock.

AssertSet<T>(T, Action<T>, Occurs, String)

Asserts the specific call

Declaration
public static void AssertSet<T>(this T obj, Action<T> action, Occurs occurs, string message = null)
Parameters
T obj

Target mock object

System.Action<T> action

Propert set action

Occurs occurs

Specifies the number of times a set action should occur.

System.String message

A message to display if the assertion fails.

Type Parameters
T

Type of the mock.

Raise<T>(T, Action<T>, EventArgs)

Raises the specified event. If the event is not mocked and is declared on a C# or VB class and has the default implementation for add/remove, then that event can also be raised using this method, even with the profiler off.

Declaration
public static void Raise<T>(this T obj, Action<T> eventExpression, EventArgs args)
Parameters
T obj

Target instance.

System.Action<T> eventExpression

Event expression.

System.EventArgs args

EventArgs argument.

Type Parameters
T

Type of the object.

Remarks

Use this method for raising events based on System.EventHandler. The instance given in the event expression is used as an argument for the 'sender' parameter.

Raise<T>(T, Action<T>, Object[])

Raises the specified event. If the event is not mocked and is declared on a C# or VB class and has the default implementation for add/remove, then that event can also be raised using this method, even with the profiler off.

Declaration
public static void Raise<T>(this T obj, Action<T> eventExpression, params object[] args)
Parameters
T obj

Target instance.

System.Action<T> eventExpression

Event expression.

System.Object[] args

Delegate arguments.

Type Parameters
T

Type of the object.

Getting Started
  • Unit Testing and Mocking Explained
  • Videos
  • FAQs
Community
  • Forums
  • Blogs
  • Feedback Portal

Copyright © 2019 Progress Software Corporation and/or its subsidiaries or affiliates.
All Rights Reserved.

Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks for appropriate markings.