ClassFluentHelper
Contains fluent extensions for setting up or asserting mock expectations.
Definition
Namespace:Telerik.JustMock.Helpers
Assembly:Telerik.JustMock.dll
Syntax:
public static class FluentHelper
Inheritance: objectFluentHelper
Methods
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
obj
T
Target instance.
expression
Expression<Func<T, TResult>>
Target expression.
Returns
FuncExpectation<TResult>
Reference to FuncExpectation<TReturn> to setup the mock.
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
obj
T
Target instance.
expression
Expression<Action<T>>
Target expression.
Returns
Reference to ActionExpectation to setup the mock.
ArrangeLike<T>(T, Expression<Func<T, bool>>)
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
mock
T
The mock on which to make the arrangements.
functionalSpecification
Expression<Func<T, bool>>
The functional specification to apply to this 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
obj
T
Target mock object
action
Action<T>
Propery set action
Returns
Reference to ActionExpectation to setup the mock.
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
obj
T
Target object.
expression
Expression<Func<T, TReturn>>
Target expression
occurs
Specifies the number of times a mock call should occur.
message
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
obj
T
Target object.
action
Expression<Func<T, TReturn>>
Target action.
message
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
obj
T
Target mock object
expression
Expression<Action<T>>
Target expression
occurs
Specifies the number of times a mock call should occur.
message
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
obj
T
Target object.
action
Expression<Action<T>>
Target action.
message
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
target
T
Target instance.
message
AssertAll<T>(T, string)
Asserts all expected setups.
Declaration
public static void AssertAll<T>(this T target, string message = null)
Parameters
target
T
Target instance.
message
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
obj
T
Target mock object
action
Action<T>
Propert set action
occurs
Specifies the number of times a set action should occur.
message
A message to display if the assertion fails.
AssertSet<T>(T, Action<T>, string)
Asserts the specific call
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
obj
T
Target instance.
eventExpression
Action<T>
Event expression.
args
EventArgs argument.
Remarks
Use this method for raising events based on EventHandler. The instance given in the event expression is used as an argument for the 'sender' parameter.
Raise<T>(T, Action<T>, params 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.