Class FluentHelper
Contains fluent extensions for setting up or asserting mock expectations.
Inheritance
Inherited Members
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. |