New to Telerik JustMockStart a free 30-day trial

Defines methods to mock non-public members.

Definition

Namespace:Telerik.JustMock.Expectations.Abstraction

Assembly:Telerik.JustMock.dll

Syntax:

C#
public interface INonPublicExpectation

Properties

Non public ref return interface for mocking.

C#
INonPublicRefReturnExpectation RefReturn { get; }

Methods

Arranges an expectation on a void method given using a dynamic wrapper built with Wrap().

C#
ActionExpectation Arrange(dynamic dynamicExpression)
Parameters:dynamicExpressiondynamic

An expression built using a wrapper returned by Wrap.

Returns:

ActionExpectation

An expectation object that can further configure the arrangement

Arranges a method for mocking.

C#
ActionExpectation Arrange(MethodBase method, params object[] args)
Parameters:methodMethodBase

Target method

argsobject[]

Method arguments. Use Expr for predefined argument matchers.

Returns:

ActionExpectation

Setups a non-public method for mocking.

C#
ActionExpectation Arrange(object target, MethodInfo method, params object[] args)
Parameters:targetobject

Target instance

methodMethodInfo

Method to setup taken from reflection.

argsobject[]

Method arguments. Use Expr for predefined argument matchers.

Returns:

ActionExpectation

Reference to setup actions calls

Arranges a method for mocking.

C#
ActionExpectation Arrange(object target, string memberName, params object[] args)
Parameters:targetobject

Target instance

memberNamestring

Member name

argsobject[]

Method arguments. Use Expr for predefined argument matchers.

Returns:

ActionExpectation

Reference to setup actions calls

Arranges a method for mocking.

C#
ActionExpectation Arrange(object target, string memberName, Type[] typeArguments, params object[] args)
Parameters:targetobject

Target instance

memberNamestring

Member name

typeArgumentsType[]

Generic type arguments of the member specified by memberName

argsobject[]

Method arguments. Use Expr for predefined argument matchers.

Returns:

ActionExpectation

Reference to setup actions calls

Arranges a method for mocking.

C#
ActionExpectation Arrange(Type targetType, string memberName, params object[] args)
Parameters:targetTypeType

Target type

memberNamestring

Target member name

argsobject[]

Method arguments. Use Expr for predefined argument matchers.

Returns:

ActionExpectation

Arranges a method for mocking.

C#
ActionExpectation Arrange(Type targetType, string memberName, Type[] typeArguments, params object[] args)
Parameters:targetTypeType

Target type

memberNamestring

Target member name

typeArgumentsType[]

Generic type arguments of the member specified by memberName

argsobject[]

Method arguments. Use Expr for predefined argument matchers.

Returns:

ActionExpectation

Arranges a method for mocking.

C#
FuncExpectation<TReturn> Arrange<T, TReturn>(string memberName, params object[] args)
Parameters:memberNamestring

Target member name

argsobject[]

Method arguments. Use Expr for predefined argument matchers.

Returns:

FuncExpectation<TReturn>

Arranges a method for mocking.

C#
FuncExpectation<TReturn> Arrange<T, TReturn>(string memberName, Type[] typeArguments, params object[] args)
Parameters:memberNamestring

Target member name

typeArgumentsType[]

Generic type arguments of the member specified by memberName

argsobject[]

Method arguments. Use Expr for predefined argument matchers.

Returns:

FuncExpectation<TReturn>

Arranges a method for mocking.

C#
ActionExpectation Arrange<T>(string memberName, params object[] args)
Parameters:memberNamestring

Target member name

argsobject[]

Method arguments. Use Expr for predefined argument matchers.

Returns:

ActionExpectation

Arranges a method for mocking.

C#
ActionExpectation Arrange<T>(string memberName, Type[] typeArguments, params object[] args)
Parameters:memberNamestring

Target member name

typeArgumentsType[]

Generic type arguments of the member specified by memberName

argsobject[]

Method arguments. Use Expr for predefined argument matchers.

Returns:

ActionExpectation

Arranges an expectation on a non-void method given using a dynamic wrapper built with Wrap().

C#
FuncExpectation<TReturn> Arrange<TReturn>(dynamic dynamicExpression)
Parameters:dynamicExpressiondynamic

An expression built using a wrapper returned by Wrap.

Returns:

FuncExpectation<TReturn>

An expectation object that can further configure the arrangement

Arranges a method for mocking.

C#
FuncExpectation<TReturn> Arrange<TReturn>(MethodBase method, params object[] args)
Parameters:methodMethodBase

Target method

argsobject[]

Method arguments. Use Expr for predefined argument matchers.

Returns:

FuncExpectation<TReturn>

Setups a non-public method for mocking.

C#
FuncExpectation<TReturn> Arrange<TReturn>(object target, MethodInfo method, params object[] args)
Parameters:targetobject

Target instance

methodMethodInfo

Method to setup taken from reflection.

argsobject[]

Method arguments. Use Expr for predefined argument matchers.

Returns:

FuncExpectation<TReturn>

Reference to setup actions calls

Arranges a method for mocking.

C#
FuncExpectation<TReturn> Arrange<TReturn>(object target, string memberName, params object[] args)
Parameters:targetobject

Target instance.

memberNamestring

Target member name

argsobject[]

Method arguments. Use Expr for predefined argument matchers.

Returns:

FuncExpectation<TReturn>

Arranges a method for mocking.

C#
FuncExpectation<TReturn> Arrange<TReturn>(object target, string memberName, Type[] typeArguments, params object[] args)
Parameters:targetobject

Target instance.

memberNamestring

Target member name

typeArgumentsType[]

Generic type arguments of the member specified by memberName

argsobject[]

Method arguments. Use Expr for predefined argument matchers.

Returns:

FuncExpectation<TReturn>

Arranges a method for mocking.

C#
FuncExpectation<TReturn> Arrange<TReturn>(Type targetType, string memberName, params object[] args)
Parameters:targetTypeType

Target type

memberNamestring

Target member name

argsobject[]

Method arguments. Use Expr for predefined argument matchers.

Returns:

FuncExpectation<TReturn>

Arranges a method for mocking.

C#
FuncExpectation<TReturn> Arrange<TReturn>(Type targetType, string memberName, Type[] typeArguments, params object[] args)
Parameters:targetTypeType

Target type

memberNamestring

Target member name

typeArgumentsType[]

Generic type arguments of the member specified by memberName

argsobject[]

Method arguments. Use Expr for predefined argument matchers.

Returns:

FuncExpectation<TReturn>

Arranges a non-public property setter for mocking.

C#
ActionExpectation ArrangeSet(object target, string propertyName, object value)
Parameters:targetobject

Target instance

propertyNamestring

Property name

valueobject

Property value. Use Expr for predefined argument matchers.

Returns:

ActionExpectation

Reference to setup actions calls

Arranges a non-public static property setter contained by "type" for mocking.

C#
ActionExpectation ArrangeSet(Type type, string propertyName, object value)
Parameters:typeType

Type that contains the non-public static property

propertyNamestring

Property name

valueobject

Property value. Use Expr for predefined argument matchers.

Returns:

ActionExpectation

Reference to setup actions calls

Arranges a non-public static property setter contained by type parameter "T" for mocking.

C#
ActionExpectation ArrangeSet<T>(string propertyName, object value)
Parameters:propertyNamestring

Property name

valueobject

Property value. Use Expr for predefined argument matchers.

Returns:

ActionExpectation

Reference to setup actions calls

Asserts an expectation given using a dynamic wrapper built with Wrap()

C#
void Assert(dynamic dynamicExpression, Args args, Occurs occurs, string message = null)
Parameters:dynamicExpressiondynamic

An expression built using a wrapper returned by Wrap.

argsArgs

Additional arguments to clarify the assertion expression.

occursOccurs

Occurrence expectation to assert.

messagestring

A message to display if the assertion fails.

Asserts an expectation given using a dynamic wrapper built with Wrap()

C#
void Assert(dynamic dynamicExpression, Occurs occurs, string message = null)
Parameters:dynamicExpressiondynamic

An expression built using a wrapper returned by Wrap.

occursOccurs

Occurrence expectation to assert.

messagestring

A message to display if the assertion fails.

Asserts the specified method that it is called as expected.

C#
void Assert(MethodBase method, Occurs occurs, params object[] args)
Parameters:methodMethodBase

Target method

occursOccurs

Specifies the number of times a call should occur.

argsobject[]

Method arguments

Asserts the specified method that it is called as expected.

C#
void Assert(MethodBase method, params object[] args)
Parameters:methodMethodBase

Target method

argsobject[]

Method arguments

Asserts the specified method that it is called as expected.

C#
void Assert(object target, MethodInfo method, Occurs occurs, params object[] args)
Parameters:targetobject

Target mock

methodMethodInfo

Method to assert taken from reflection.

occursOccurs

Specifies the number of times a call should occur.

argsobject[]

Method arguments

Asserts the specified method that it is called as expected.

C#
void Assert(object target, MethodInfo method, params object[] args)
Parameters:targetobject

Target mock

methodMethodInfo

Method to assert taken from reflection.

argsobject[]

Method arguments

Asserts the specified member that it is called as expected.

C#
void Assert(object target, string memberName, Occurs occurs, params object[] args)
Parameters:targetobject

Target mock

memberNamestring

Name of the member

occursOccurs

Specifies the number of times a call should occur.

argsobject[]

Method arguments

Asserts the specified member that it is called as expected.

C#
void Assert(object target, string memberName, params object[] args)
Parameters:targetobject

Target mock

memberNamestring

Name of the member

argsobject[]

Method arguments

Asserts the specified member that it is called as expected.

C#
void Assert(object target, string memberName, Type[] typeArguments, Occurs occurs, params object[] args)
Parameters:targetobject

Target mock

memberNamestring

Name of the member

typeArgumentsType[]

Generic type arguments of the member specified by memberName

occursOccurs

Specifies the number of times a call should occur.

argsobject[]

Method arguments

Asserts the specified member that it is called as expected.

C#
void Assert(object target, string memberName, Type[] typeArguments, params object[] args)
Parameters:targetobject

Target mock

memberNamestring

Name of the member

typeArgumentsType[]

Generic type arguments of the member specified by memberName

argsobject[]

Method arguments

Asserts the specified member that it is called as expected.

C#
void Assert(Type targetType, string memberName, Occurs occurs, params object[] args)
Parameters:targetTypeType

Type of the target

memberNamestring

Name of the member

occursOccurs

Specifies the number of times a call should occur.

argsobject[]

Method arguments

Asserts the specified member that it is called as expected.

C#
void Assert(Type targetType, string memberName, params object[] args)
Parameters:targetTypeType

Type of the target

memberNamestring

Name of the member

argsobject[]

Method arguments

Asserts the specified member that it is called as expected.

C#
void Assert(Type targetType, string memberName, Type[] typeArguments, Occurs occurs, params object[] args)
Parameters:targetTypeType

Type of the target

memberNamestring

Name of the member

typeArgumentsType[]

Generic type arguments of the member specified by memberName

occursOccurs

Specifies the number of times a call should occur.

argsobject[]

Method arguments

Asserts the specified member that it is called as expected.

C#
void Assert(Type targetType, string memberName, Type[] typeArguments, params object[] args)
Parameters:targetTypeType

Type of the target

memberNamestring

Name of the member

typeArgumentsType[]

Generic type arguments of the member specified by memberName

argsobject[]

Method arguments

Asserts the specified member that it is called as expected.

C#
void Assert<T, TReturn>(string memberName, Occurs occurs, params object[] args)
Parameters:memberNamestring

Name of the member

occursOccurs

Specifies the number of times a call should occur.

argsobject[]

Method arguments

Asserts the specified member that it is called as expected.

C#
void Assert<T, TReturn>(string memberName, params object[] args)
Parameters:memberNamestring

Name of the member

argsobject[]

Method arguments

Asserts the specified member that it is called as expected.

C#
void Assert<T, TReturn>(string memberName, Type[] typeArguments, Occurs occurs, params object[] args)
Parameters:memberNamestring

Name of the member

typeArgumentsType[]

Generic type arguments of the member specified by memberName

occursOccurs

Specifies the number of times a call should occur.

argsobject[]

Method arguments

Asserts the specified member that it is called as expected.

C#
void Assert<T, TReturn>(string memberName, Type[] typeArguments, params object[] args)
Parameters:memberNamestring

Name of the member

typeArgumentsType[]

Generic type arguments of the member specified by memberName

argsobject[]

Method arguments

Asserts the specified member that it is called as expected.

C#
void Assert<T>(string memberName, Occurs occurs, params object[] args)
Parameters:memberNamestring

Name of the member

occursOccurs

Specifies the number of times a call should occur.

argsobject[]

Method arguments

Asserts the specified member that it is called as expected.

C#
void Assert<T>(string memberName, params object[] args)
Parameters:memberNamestring

Name of the member

argsobject[]

Method arguments

Asserts the specified member that it is called as expected.

C#
void Assert<T>(string memberName, Type[] typeArguments, Occurs occurs, params object[] args)
Parameters:memberNamestring

Name of the member

typeArgumentsType[]

Generic type arguments of the member specified by memberName

occursOccurs

Specifies the number of times a call should occur.

argsobject[]

Method arguments

Asserts the specified member that it is called as expected.

C#
void Assert<T>(string memberName, Type[] typeArguments, params object[] args)
Parameters:memberNamestring

Name of the member

typeArgumentsType[]

Generic type arguments of the member specified by memberName

argsobject[]

Method arguments

Asserts the specified member that it is called as expected.

C#
void Assert<TReturn>(object target, string memberName, Occurs occurs, params object[] args)
Parameters:targetobject

Target mock

memberNamestring

Name of the member

occursOccurs

Specifies the number of times a call should occur.

argsobject[]

Method arguments

Asserts the specified member that it is called as expected.

C#
void Assert<TReturn>(object target, string memberName, params object[] args)
Parameters:targetobject

Target mock

memberNamestring

Name of the member

argsobject[]

Method arguments

Asserts the specified member that it is called as expected.

C#
void Assert<TReturn>(object target, string memberName, Type[] typeArguments, Occurs occurs, params object[] args)
Parameters:targetobject

Target mock

memberNamestring

Name of the member

typeArgumentsType[]

Generic type arguments of the member specified by memberName

occursOccurs

Specifies the number of times a call should occur.

argsobject[]

Method arguments

Asserts the specified member that it is called as expected.

C#
void Assert<TReturn>(object target, string memberName, Type[] typeArguments, params object[] args)
Parameters:targetobject

Target mock

memberNamestring

Name of the member

typeArgumentsType[]argsobject[]

Method arguments

Asserts the specified member that it is called as expected.

C#
void Assert<TReturn>(Type targetType, string memberName, Occurs occurs, params object[] args)
Parameters:targetTypeType

Type of the target

memberNamestring

Name of the member

occursOccurs

Specifies the number of times a call should occur.

argsobject[]

Method arguments

Asserts the specified member that it is called as expected.

C#
void Assert<TReturn>(Type targetType, string memberName, params object[] args)
Parameters:targetTypeType

Type of the target

memberNamestring

Name of the member

argsobject[]

Method arguments

Asserts the specified member that it is called as expected.

C#
void Assert<TReturn>(Type targetType, string memberName, Type[] typeArguments, Occurs occurs, params object[] args)
Parameters:targetTypeType

Type of the target

memberNamestring

Name of the member

typeArgumentsType[]

Generic type arguments of the member specified by memberName

occursOccurs

Specifies the number of times a call should occur.

argsobject[]

Method arguments

Asserts the specified member that it is called as expected.

C#
void Assert<TReturn>(Type targetType, string memberName, Type[] typeArguments, params object[] args)
Parameters:targetTypeType

Type of the target

memberNamestring

Name of the member

typeArgumentsType[]

Generic type arguments of the member specified by memberName

argsobject[]

Method arguments

Returns the number of times the specified member was called.

C#
int GetTimesCalled(MethodBase method, params object[] args)
Parameters:methodMethodBase

Target method

argsobject[]

Method arguments

Returns:

int

Number of calls.

Returns the number of times the specified member was called.

C#
int GetTimesCalled(object target, MethodInfo method, params object[] args)
Parameters:targetobject

Target mock

methodMethodInfo

Method taken from reflection

argsobject[]

Method arguments

Returns:

int

Number of calls.

Returns the number of times the specified member was called.

C#
int GetTimesCalled(object target, string memberName, params object[] args)
Parameters:targetobject

Target mock

memberNamestring

Name of the member

argsobject[]

Method arguments

Returns:

int

Number of calls.

Returns the number of times the specified member was called.

C#
int GetTimesCalled(object target, string memberName, Type[] typeArguments, params object[] args)
Parameters:targetobject

Target mock

memberNamestring

Name of the member

typeArgumentsType[]

Generic type arguments of the member specified by memberName

argsobject[]

Method arguments

Returns:

int

Number of calls.

Returns the number of times the specified member was called.

C#
int GetTimesCalled(Type type, string memberName, params object[] args)
Parameters:typeType

Type of the target

memberNamestring

Name of the member

argsobject[]

Method arguments

Returns:

int

Number of calls.

Returns the number of times the specified member was called.

C#
int GetTimesCalled(Type type, string memberName, Type[] typeArguments, params object[] args)
Parameters:typeType

Type of the target

memberNamestring

Name of the member

typeArgumentsType[]

Generic type arguments of the member specified by memberName

argsobject[]

Method arguments

Returns:

int

Number of calls.

        Creates an accessor object that can invoke non-public methods and get/set non-public properties and fields.
        Equivalent to 
csharp
new PrivateAccessor(instance)

.

C#
PrivateAccessor MakePrivateAccessor(object instance)
Parameters:instanceobject

Instance to which non-public access will be given.

Returns:

PrivateAccessor

Non-public accessor.

        Creates an accessor object that can invoke static (Shared in Visual Basic) non-public methods and static get/set non-public properties and fields.
        Equivalent to 
csharp
PrivateAccessor.ForType(type)

.

C#
PrivateAccessor MakeStaticPrivateAccessor(Type type)
Parameters:typeType

Type whose static members will be given non-public access to.

Returns:

PrivateAccessor

Non-public accessor.

Raises a static event specified using reflection. If the event 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.

C#
void Raise(EventInfo eventInfo, params object[] args)
Parameters:eventInfoEventInfo

The event to raise.

argsobject[]

Arguments to pass to the event handlers.

Raises an event specified using reflection. If the event 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.

C#
void Raise(object instance, EventInfo eventInfo, params object[] args)
Parameters:instanceobject

Instance on which to raise the event.

eventInfoEventInfo

The event to raise.

argsobject[]

Arguments to pass to the event handlers.

Raises an event by name. If the event 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.

C#
void Raise(object instance, string eventName, params object[] args)
Parameters:instanceobject

Instance on which to raise the event.

eventNamestring

The name of event to raise.

argsobject[]

Arguments to pass to the event handlers.

Raises a static event by name. If the event 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.

C#
void Raise(Type type, string eventName, params object[] args)
Parameters:typeType

The type on which the event is declared.

eventNamestring

The name of event to raise.

argsobject[]

Arguments to pass to the event handlers.

Returns a dynamic wrapper of the given object that can be used to arrange non-public instance members on the object.

C#
dynamic Wrap(object instance)
Parameters:instanceobject

The object to wrap.

Returns:

dynamic

A wrapper that can be passed to Arrange.

Returns a dynamic wrapper of the given type that can be used to arrange non-public static members on the type.

C#
dynamic WrapType(Type type)
Parameters:typeType

The type to wrap.

Returns:

dynamic

A wrapper that can be passed to Arrange.

In this article
DefinitionPropertiesRefReturnMethodsArrange(dynamic)Arrange(MethodBase, params object[])Arrange(object, MethodInfo, params object[])Arrange(object, string, params object[])Arrange(object, string, Type[], params object[])Arrange(Type, string, params object[])Arrange(Type, string, Type[], params object[])Arrange<T, TReturn>(string, params object[])Arrange<T, TReturn>(string, Type[], params object[])Arrange<T>(string, params object[])Arrange<T>(string, Type[], params object[])Arrange<TReturn>(dynamic)Arrange<TReturn>(MethodBase, params object[])Arrange<TReturn>(object, MethodInfo, params object[])Arrange<TReturn>(object, string, params object[])Arrange<TReturn>(object, string, Type[], params object[])Arrange<TReturn>(Type, string, params object[])Arrange<TReturn>(Type, string, Type[], params object[])ArrangeSet(object, string, object)ArrangeSet(Type, string, object)ArrangeSet<T>(string, object)Assert(dynamic, Args, Occurs, string)Assert(dynamic, Occurs, string)Assert(MethodBase, Occurs, params object[])Assert(MethodBase, params object[])Assert(object, MethodInfo, Occurs, params object[])Assert(object, MethodInfo, params object[])Assert(object, string, Occurs, params object[])Assert(object, string, params object[])Assert(object, string, Type[], Occurs, params object[])Assert(object, string, Type[], params object[])Assert(Type, string, Occurs, params object[])Assert(Type, string, params object[])Assert(Type, string, Type[], Occurs, params object[])Assert(Type, string, Type[], params object[])Assert<T, TReturn>(string, Occurs, params object[])Assert<T, TReturn>(string, params object[])Assert<T, TReturn>(string, Type[], Occurs, params object[])Assert<T, TReturn>(string, Type[], params object[])Assert<T>(string, Occurs, params object[])Assert<T>(string, params object[])Assert<T>(string, Type[], Occurs, params object[])Assert<T>(string, Type[], params object[])Assert<TReturn>(object, string, Occurs, params object[])Assert<TReturn>(object, string, params object[])Assert<TReturn>(object, string, Type[], Occurs, params object[])Assert<TReturn>(object, string, Type[], params object[])Assert<TReturn>(Type, string, Occurs, params object[])Assert<TReturn>(Type, string, params object[])Assert<TReturn>(Type, string, Type[], Occurs, params object[])Assert<TReturn>(Type, string, Type[], params object[])GetTimesCalled(MethodBase, params object[])GetTimesCalled(object, MethodInfo, params object[])GetTimesCalled(object, string, params object[])GetTimesCalled(object, string, Type[], params object[])GetTimesCalled(Type, string, params object[])GetTimesCalled(Type, string, Type[], params object[])MakePrivateAccessor(object)MakeStaticPrivateAccessor(Type)Raise(EventInfo, params object[])Raise(object, EventInfo, params object[])Raise(object, string, params object[])Raise(Type, string, params object[])Wrap(object)WrapType(Type)
Not finding the help you need?
Contact Support