InterfaceINonPublicExpectation
Defines methods to mock non-public members.
Definition
Namespace:Telerik.JustMock.Expectations.Abstraction
Assembly:Telerik.JustMock.dll
Syntax:
public interface INonPublicExpectation
Properties
RefReturn
Non public ref return interface for mocking.
Declaration
INonPublicRefReturnExpectation RefReturn { get; }
Property Value
Methods
Arrange(MethodBase, params object[])
Arranges a method for mocking.
Arrange(Type, string, Type[], params object[])
Arranges a method for mocking.
Declaration
ActionExpectation Arrange(Type targetType, string memberName, Type[] typeArguments, params object[] args)
Parameters
targetType
Target type
memberName
Target member name
typeArguments
Type[]
Generic type arguments of the member specified by memberName
args
object[]
Method arguments. Use Expr for predefined argument matchers.
Returns
Arrange(Type, string, params object[])
Arranges a method for mocking.
Arrange(dynamic)
Arranges an expectation on a void method given using a dynamic wrapper built with Wrap().
Declaration
ActionExpectation Arrange(dynamic dynamicExpression)
Parameters
dynamicExpression
dynamic
An expression built using a wrapper returned by Wrap.
Returns
An expectation object that can further configure the arrangement
Example
var mock = Mock.NonPublic.Wrap(myobj); Mock.NonPublic.Arrange(mock.PrivateMethod(ArgExpr.IsAny<int>()).DoNothing(); Mock.NonPublic.Arrange(mock.Value = ArgExpr.IsAny<int>()).MustBeCalled();
var staticMock = Mock.NonPublic.WrapType(typeof(MyType)); Mock.NonPublic.Arrange(staticMock.PrivateMethod()).DoNothing();
Arrange(object, MethodInfo, params object[])
Setups a non-public method for mocking.
Declaration
ActionExpectation Arrange(object target, MethodInfo method, params object[] args)
Parameters
target
Target instance
method
Method to setup taken from reflection.
args
object[]
Method arguments. Use Expr for predefined argument matchers.
Returns
Reference to setup actions calls
Arrange(object, string, Type[], params object[])
Arranges a method for mocking.
Declaration
ActionExpectation Arrange(object target, string memberName, Type[] typeArguments, params object[] args)
Parameters
target
Target instance
memberName
Member name
typeArguments
Type[]
Generic type arguments of the member specified by memberName
args
object[]
Method arguments. Use Expr for predefined argument matchers.
Returns
Reference to setup actions calls
Arrange(object, string, params object[])
Arranges a method for mocking.
Arrange<T, TReturn>(string, Type[], params object[])
Arranges a method for mocking.
Declaration
FuncExpectation<TReturn> Arrange<T, TReturn>(string memberName, Type[] typeArguments, params object[] args)
Parameters
memberName
Target member name
typeArguments
Type[]
Generic type arguments of the member specified by memberName
args
object[]
Method arguments. Use Expr for predefined argument matchers.
Returns
FuncExpectation<TReturn>
Arrange<T, TReturn>(string, params object[])
Arranges a method for mocking.
Declaration
FuncExpectation<TReturn> Arrange<T, TReturn>(string memberName, params object[] args)
Parameters
memberName
Target member name
args
object[]
Method arguments. Use Expr for predefined argument matchers.
Returns
FuncExpectation<TReturn>
Arrange<T>(string, Type[], params object[])
Arranges a method for mocking.
Declaration
ActionExpectation Arrange<T>(string memberName, Type[] typeArguments, params object[] args)
Parameters
memberName
Target member name
typeArguments
Type[]
Generic type arguments of the member specified by memberName
args
object[]
Method arguments. Use Expr for predefined argument matchers.
Returns
Arrange<T>(string, params object[])
Arranges a method for mocking.
Arrange<TReturn>(MethodBase, params object[])
Arranges a method for mocking.
Declaration
FuncExpectation<TReturn> Arrange<TReturn>(MethodBase method, params object[] args)
Parameters
method
Target method
args
object[]
Method arguments. Use Expr for predefined argument matchers.
Returns
FuncExpectation<TReturn>
Arrange<TReturn>(Type, string, Type[], params object[])
Arranges a method for mocking.
Declaration
FuncExpectation<TReturn> Arrange<TReturn>(Type targetType, string memberName, Type[] typeArguments, params object[] args)
Parameters
targetType
Target type
memberName
Target member name
typeArguments
Type[]
Generic type arguments of the member specified by memberName
args
object[]
Method arguments. Use Expr for predefined argument matchers.
Returns
FuncExpectation<TReturn>
Arrange<TReturn>(Type, string, params object[])
Arranges a method for mocking.
Declaration
FuncExpectation<TReturn> Arrange<TReturn>(Type targetType, string memberName, params object[] args)
Parameters
targetType
Target type
memberName
Target member name
args
object[]
Method arguments. Use Expr for predefined argument matchers.
Returns
FuncExpectation<TReturn>
Arrange<TReturn>(dynamic)
Arranges an expectation on a non-void method given using a dynamic wrapper built with Wrap().
Declaration
FuncExpectation<TReturn> Arrange<TReturn>(dynamic dynamicExpression)
Parameters
dynamicExpression
dynamic
An expression built using a wrapper returned by Wrap.
Returns
FuncExpectation<TReturn>
An expectation object that can further configure the arrangement
Example
var mock = Mock.NonPublic.Wrap(myobj); Mock.NonPublic.Arrange<int>(mock.PrivateValue).Returns(123); Mock.NonPublic.Arrange<string>(mock.GetNamePrivate(123)).Returns("me");
Arrange<TReturn>(object, MethodInfo, params object[])
Setups a non-public method for mocking.
Declaration
FuncExpectation<TReturn> Arrange<TReturn>(object target, MethodInfo method, params object[] args)
Parameters
target
Target instance
method
Method to setup taken from reflection.
args
object[]
Method arguments. Use Expr for predefined argument matchers.
Returns
FuncExpectation<TReturn>
Reference to setup actions calls
Arrange<TReturn>(object, string, Type[], params object[])
Arranges a method for mocking.
Declaration
FuncExpectation<TReturn> Arrange<TReturn>(object target, string memberName, Type[] typeArguments, params object[] args)
Parameters
target
Target instance.
memberName
Target member name
typeArguments
Type[]
Generic type arguments of the member specified by memberName
args
object[]
Method arguments. Use Expr for predefined argument matchers.
Returns
FuncExpectation<TReturn>
Arrange<TReturn>(object, string, params object[])
Arranges a method for mocking.
Declaration
FuncExpectation<TReturn> Arrange<TReturn>(object target, string memberName, params object[] args)
Parameters
target
Target instance.
memberName
Target member name
args
object[]
Method arguments. Use Expr for predefined argument matchers.
Returns
FuncExpectation<TReturn>
ArrangeSet(Type, string, object)
Arranges a non-public static property setter contained by "type" for mocking.
Declaration
ActionExpectation ArrangeSet(Type type, string propertyName, object value)
Parameters
type
Type that contains the non-public static property
propertyName
Property name
value
Property value. Use Expr for predefined argument matchers.
Returns
Reference to setup actions calls
ArrangeSet(object, string, object)
Arranges a non-public property setter for mocking.
Declaration
ActionExpectation ArrangeSet(object target, string propertyName, object value)
Parameters
target
Target instance
propertyName
Property name
value
Property value. Use Expr for predefined argument matchers.
Returns
Reference to setup actions calls
ArrangeSet<T>(string, object)
Arranges a non-public static property setter contained by type parameter "T" for mocking.
Declaration
ActionExpectation ArrangeSet<T>(string propertyName, object value)
Parameters
propertyName
Property name
value
Property value. Use Expr for predefined argument matchers.
Returns
Reference to setup actions calls
Assert(MethodBase, Occurs, params object[])
Asserts the specified method that it is called as expected.
Declaration
void Assert(MethodBase method, Occurs occurs, params object[] args)
Parameters
method
Target method
occurs
Specifies the number of times a call should occur.
args
object[]
Method arguments
Assert(MethodBase, params object[])
Asserts the specified method that it is called as expected.
Declaration
void Assert(MethodBase method, params object[] args)
Parameters
method
Target method
args
object[]
Method arguments
Assert(Type, string, Occurs, params object[])
Asserts the specified member that it is called as expected.
Assert(Type, string, Type[], Occurs, params object[])
Asserts the specified member that it is called as expected.
Declaration
void Assert(Type targetType, string memberName, Type[] typeArguments, Occurs occurs, params object[] args)
Parameters
targetType
Type of the target
memberName
Name of the member
typeArguments
Type[]
Generic type arguments of the member specified by memberName
occurs
Specifies the number of times a call should occur.
args
object[]
Method arguments
Assert(Type, string, Type[], params object[])
Asserts the specified member that it is called as expected.
Declaration
void Assert(Type targetType, string memberName, Type[] typeArguments, params object[] args)
Parameters
targetType
Type of the target
memberName
Name of the member
typeArguments
Type[]
Generic type arguments of the member specified by memberName
args
object[]
Method arguments
Assert(Type, string, params object[])
Asserts the specified member that it is called as expected.
Assert(dynamic, Args, Occurs, string)
Asserts an expectation given using a dynamic wrapper built with Wrap()
Declaration
void Assert(dynamic dynamicExpression, Args args, Occurs occurs, string message = null)
Parameters
dynamicExpression
dynamic
An expression built using a wrapper returned by Wrap.
args
Additional arguments to clarify the assertion expression.
occurs
Occurrence expectation to assert.
message
A message to display if the assertion fails.
Assert(dynamic, Occurs, string)
Asserts an expectation given using a dynamic wrapper built with Wrap()
Declaration
void Assert(dynamic dynamicExpression, Occurs occurs, string message = null)
Parameters
dynamicExpression
dynamic
An expression built using a wrapper returned by Wrap.
occurs
Occurrence expectation to assert.
message
A message to display if the assertion fails.
Assert(object, MethodInfo, Occurs, params object[])
Asserts the specified method that it is called as expected.
Declaration
void Assert(object target, MethodInfo method, Occurs occurs, params object[] args)
Parameters
target
Target mock
method
Method to assert taken from reflection.
occurs
Specifies the number of times a call should occur.
args
object[]
Method arguments
Assert(object, MethodInfo, params object[])
Asserts the specified method that it is called as expected.
Declaration
void Assert(object target, MethodInfo method, params object[] args)
Parameters
target
Target mock
method
Method to assert taken from reflection.
args
object[]
Method arguments
Assert(object, string, Occurs, params object[])
Asserts the specified member that it is called as expected.
Assert(object, string, Type[], Occurs, params object[])
Asserts the specified member that it is called as expected.
Declaration
void Assert(object target, string memberName, Type[] typeArguments, Occurs occurs, params object[] args)
Parameters
target
Target mock
memberName
Name of the member
typeArguments
Type[]
Generic type arguments of the member specified by memberName
occurs
Specifies the number of times a call should occur.
args
object[]
Method arguments
Assert(object, string, Type[], params object[])
Asserts the specified member that it is called as expected.
Assert(object, string, params object[])
Asserts the specified member that it is called as expected.
Assert<T, TReturn>(string, Occurs, params object[])
Asserts the specified member that it is called as expected.
Assert<T, TReturn>(string, Type[], Occurs, params object[])
Asserts the specified member that it is called as expected.
Declaration
void Assert<T, TReturn>(string memberName, Type[] typeArguments, Occurs occurs, params object[] args)
Parameters
memberName
Name of the member
typeArguments
Type[]
Generic type arguments of the member specified by memberName
occurs
Specifies the number of times a call should occur.
args
object[]
Method arguments
Assert<T, TReturn>(string, Type[], params object[])
Asserts the specified member that it is called as expected.
Assert<T, TReturn>(string, params object[])
Asserts the specified member that it is called as expected.
Assert<T>(string, Occurs, params object[])
Asserts the specified member that it is called as expected.
Assert<T>(string, Type[], Occurs, params object[])
Asserts the specified member that it is called as expected.
Declaration
void Assert<T>(string memberName, Type[] typeArguments, Occurs occurs, params object[] args)
Parameters
memberName
Name of the member
typeArguments
Type[]
Generic type arguments of the member specified by memberName
occurs
Specifies the number of times a call should occur.
args
object[]
Method arguments
Assert<T>(string, Type[], params object[])
Asserts the specified member that it is called as expected.
Assert<T>(string, params object[])
Asserts the specified member that it is called as expected.
Assert<TReturn>(Type, string, Occurs, params object[])
Asserts the specified member that it is called as expected.
Declaration
void Assert<TReturn>(Type targetType, string memberName, Occurs occurs, params object[] args)
Parameters
targetType
Type of the target
memberName
Name of the member
occurs
Specifies the number of times a call should occur.
args
object[]
Method arguments
Assert<TReturn>(Type, string, Type[], Occurs, params object[])
Asserts the specified member that it is called as expected.
Declaration
void Assert<TReturn>(Type targetType, string memberName, Type[] typeArguments, Occurs occurs, params object[] args)
Parameters
targetType
Type of the target
memberName
Name of the member
typeArguments
Type[]
Generic type arguments of the member specified by memberName
occurs
Specifies the number of times a call should occur.
args
object[]
Method arguments
Assert<TReturn>(Type, string, Type[], params object[])
Asserts the specified member that it is called as expected.
Declaration
void Assert<TReturn>(Type targetType, string memberName, Type[] typeArguments, params object[] args)
Parameters
targetType
Type of the target
memberName
Name of the member
typeArguments
Type[]
Generic type arguments of the member specified by memberName
args
object[]
Method arguments
Assert<TReturn>(Type, string, params object[])
Asserts the specified member that it is called as expected.
Assert<TReturn>(object, string, Occurs, params object[])
Asserts the specified member that it is called as expected.
Assert<TReturn>(object, string, Type[], Occurs, params object[])
Asserts the specified member that it is called as expected.
Declaration
void Assert<TReturn>(object target, string memberName, Type[] typeArguments, Occurs occurs, params object[] args)
Parameters
target
Target mock
memberName
Name of the member
typeArguments
Type[]
Generic type arguments of the member specified by memberName
occurs
Specifies the number of times a call should occur.
args
object[]
Method arguments
Assert<TReturn>(object, string, Type[], params object[])
Asserts the specified member that it is called as expected.
Assert<TReturn>(object, string, params object[])
Asserts the specified member that it is called as expected.
GetTimesCalled(MethodBase, params object[])
Returns the number of times the specified member was called.
Declaration
int GetTimesCalled(MethodBase method, params object[] args)
Parameters
method
Target method
args
object[]
Method arguments
Returns
Number of calls.
GetTimesCalled(Type, string, Type[], params object[])
Returns the number of times the specified member was called.
Declaration
int GetTimesCalled(Type type, string memberName, Type[] typeArguments, params object[] args)
Parameters
type
Type of the target
memberName
Name of the member
typeArguments
Type[]
Generic type arguments of the member specified by memberName
args
object[]
Method arguments
Returns
Number of calls.
GetTimesCalled(Type, string, params object[])
Returns the number of times the specified member was called.
GetTimesCalled(object, MethodInfo, params object[])
Returns the number of times the specified member was called.
Declaration
int GetTimesCalled(object target, MethodInfo method, params object[] args)
Parameters
target
Target mock
method
Method taken from reflection
args
object[]
Method arguments
Returns
Number of calls.
GetTimesCalled(object, string, Type[], params object[])
Returns the number of times the specified member was called.
Declaration
int GetTimesCalled(object target, string memberName, Type[] typeArguments, params object[] args)
Parameters
target
Target mock
memberName
Name of the member
typeArguments
Type[]
Generic type arguments of the member specified by memberName
args
object[]
Method arguments
Returns
Number of calls.
GetTimesCalled(object, string, params object[])
Returns the number of times the specified member was called.
MakePrivateAccessor(object)
Creates an accessor object that can invoke non-public methods and get/set non-public properties and fields. Equivalent to
new PrivateAccessor(instance).Declaration
PrivateAccessor MakePrivateAccessor(object instance)
Parameters
instance
Instance to which non-public access will be given.
Returns
Non-public accessor.
MakeStaticPrivateAccessor(Type)
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
PrivateAccessor.ForType(type).Declaration
PrivateAccessor MakeStaticPrivateAccessor(Type type)
Parameters
type
Type whose static members will be given non-public access to.
Returns
Non-public accessor.
Raise(EventInfo, params object[])
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.
Raise(Type, string, params object[])
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.
Raise(object, EventInfo, params object[])
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.
Raise(object, string, params object[])
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.
Wrap(object)
Returns a dynamic wrapper of the given object that can be used to arrange non-public instance members on the object.
Declaration
dynamic Wrap(object instance)
Parameters
instance
The object to wrap.
Returns
dynamic
A wrapper that can be passed to Arrange.
WrapType(Type)
Returns a dynamic wrapper of the given type that can be used to arrange non-public static members on the type.
Declaration
dynamic WrapType(Type type)
Parameters
type
The type to wrap.
Returns
dynamic
A wrapper that can be passed to Arrange.