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

Interface INonPublicExpectation

Defines methods to mock non-public members.

Namespace: Telerik.JustMock.Expectations.Abstraction
Assembly: Telerik.JustMock.dll

Syntax

public interface INonPublicExpectation
Remarks

Non-public methods are identified by their name and, optionally, by their arguments when there's a need to disambiguate between overloads, or when you need to specify matchers for the arguments using. Arguments are passed using either constant objects when a specific value needs to be matched, or using one of the members of the Expr class. If a member is not overloaded and you want the arrangement to work for all arguments, then you can specify just the name of the member and omit all arguments. This is equivalent to passing the correct Arg.Expr.IsAny<T>() arguments or adding the .IgnoreArguments() clause.

Properties

RefReturn

Non public ref return interface for mocking.

Declaration
INonPublicRefReturnExpectation RefReturn { get; }
Property Value
INonPublicRefReturnExpectation

Methods

Arrange(Object)

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

Declaration
ActionExpectation Arrange(dynamic dynamicExpression)
Parameters
System.Object dynamicExpression

An expression built using a wrapper returned by Wrap.

Returns
ActionExpectation

An expectation object that can further configure the arrangement

Examples

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, Object[])

Setups a non-public method for mocking.

Declaration
ActionExpectation Arrange(object target, MethodInfo method, params object[] args)
Parameters
System.Object target

Target instance

System.Reflection.MethodInfo method

Method to setup taken from reflection.

System.Object[] args

Method arguments. Use Expr for predefined argument matchers.

Returns
ActionExpectation

Reference to setup actions calls

Arrange(Object, String, Object[])

Arranges a method for mocking.

Declaration
ActionExpectation Arrange(object target, string memberName, params object[] args)
Parameters
System.Object target

Target instance

System.String memberName

Member name

System.Object[] args

Method arguments. Use Expr for predefined argument matchers.

Returns
ActionExpectation

Reference to setup actions calls

Arrange(Object, String, Type[], Object[])

Arranges a method for mocking.

Declaration
ActionExpectation Arrange(object target, string memberName, Type[] typeArguments, params object[] args)
Parameters
System.Object target

Target instance

System.String memberName

Member name

System.Type[] typeArguments

Generic type arguments of the member specified by memberName

System.Object[] args

Method arguments. Use Expr for predefined argument matchers.

Returns
ActionExpectation

Reference to setup actions calls

Arrange(MethodBase, Object[])

Arranges a method for mocking.

Declaration
ActionExpectation Arrange(MethodBase method, params object[] args)
Parameters
System.Reflection.MethodBase method

Target method

System.Object[] args

Method arguments. Use Expr for predefined argument matchers.

Returns
ActionExpectation

Arrange(Type, String, Object[])

Arranges a method for mocking.

Declaration
ActionExpectation Arrange(Type targetType, string memberName, params object[] args)
Parameters
System.Type targetType

Target type

System.String memberName

Target member name

System.Object[] args

Method arguments. Use Expr for predefined argument matchers.

Returns
ActionExpectation

Arrange(Type, String, Type[], Object[])

Arranges a method for mocking.

Declaration
ActionExpectation Arrange(Type targetType, string memberName, Type[] typeArguments, params object[] args)
Parameters
System.Type targetType

Target type

System.String memberName

Target member name

System.Type[] typeArguments

Generic type arguments of the member specified by memberName

System.Object[] args

Method arguments. Use Expr for predefined argument matchers.

Returns
ActionExpectation

Arrange<TReturn>(Object)

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

Declaration
FuncExpectation<TReturn> Arrange<TReturn>(dynamic dynamicExpression)
Parameters
System.Object dynamicExpression

An expression built using a wrapper returned by Wrap.

Returns
FuncExpectation<TReturn>

An expectation object that can further configure the arrangement

Type Parameters
TReturn

Examples

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, Object[])

Setups a non-public method for mocking.

Declaration
FuncExpectation<TReturn> Arrange<TReturn>(object target, MethodInfo method, params object[] args)
Parameters
System.Object target

Target instance

System.Reflection.MethodInfo method

Method to setup taken from reflection.

System.Object[] args

Method arguments. Use Expr for predefined argument matchers.

Returns
FuncExpectation<TReturn>

Reference to setup actions calls

Type Parameters
TReturn

Return type

Arrange<TReturn>(Object, String, Object[])

Arranges a method for mocking.

Declaration
FuncExpectation<TReturn> Arrange<TReturn>(object target, string memberName, params object[] args)
Parameters
System.Object target

Target instance.

System.String memberName

Target member name

System.Object[] args

Method arguments. Use Expr for predefined argument matchers.

Returns
FuncExpectation<TReturn>

Type Parameters
TReturn

Return type

Arrange<TReturn>(Object, String, Type[], Object[])

Arranges a method for mocking.

Declaration
FuncExpectation<TReturn> Arrange<TReturn>(object target, string memberName, Type[] typeArguments, params object[] args)
Parameters
System.Object target

Target instance.

System.String memberName

Target member name

System.Type[] typeArguments

Generic type arguments of the member specified by memberName

System.Object[] args

Method arguments. Use Expr for predefined argument matchers.

Returns
FuncExpectation<TReturn>

Type Parameters
TReturn

Return type

Arrange<TReturn>(MethodBase, Object[])

Arranges a method for mocking.

Declaration
FuncExpectation<TReturn> Arrange<TReturn>(MethodBase method, params object[] args)
Parameters
System.Reflection.MethodBase method

Target method

System.Object[] args

Method arguments. Use Expr for predefined argument matchers.

Returns
FuncExpectation<TReturn>

Type Parameters
TReturn

Return type

Arrange<T>(String, Object[])

Arranges a method for mocking.

Declaration
ActionExpectation Arrange<T>(string memberName, params object[] args)
Parameters
System.String memberName

Target member name

System.Object[] args

Method arguments. Use Expr for predefined argument matchers.

Returns
ActionExpectation

Type Parameters
T

Type of the target.

Arrange<T>(String, Type[], Object[])

Arranges a method for mocking.

Declaration
ActionExpectation Arrange<T>(string memberName, Type[] typeArguments, params object[] args)
Parameters
System.String memberName

Target member name

System.Type[] typeArguments

Generic type arguments of the member specified by memberName

System.Object[] args

Method arguments. Use Expr for predefined argument matchers.

Returns
ActionExpectation

Type Parameters
T

Type of the target.

Arrange<TReturn>(Type, String, Object[])

Arranges a method for mocking.

Declaration
FuncExpectation<TReturn> Arrange<TReturn>(Type targetType, string memberName, params object[] args)
Parameters
System.Type targetType

Target type

System.String memberName

Target member name

System.Object[] args

Method arguments. Use Expr for predefined argument matchers.

Returns
FuncExpectation<TReturn>

Type Parameters
TReturn

Return type

Arrange<TReturn>(Type, String, Type[], Object[])

Arranges a method for mocking.

Declaration
FuncExpectation<TReturn> Arrange<TReturn>(Type targetType, string memberName, Type[] typeArguments, params object[] args)
Parameters
System.Type targetType

Target type

System.String memberName

Target member name

System.Type[] typeArguments

Generic type arguments of the member specified by memberName

System.Object[] args

Method arguments. Use Expr for predefined argument matchers.

Returns
FuncExpectation<TReturn>

Type Parameters
TReturn

Return type

Arrange<T, TReturn>(String, Object[])

Arranges a method for mocking.

Declaration
FuncExpectation<TReturn> Arrange<T, TReturn>(string memberName, params object[] args)
Parameters
System.String memberName

Target member name

System.Object[] args

Method arguments. Use Expr for predefined argument matchers.

Returns
FuncExpectation<TReturn>

Type Parameters
T

Type of the target.

TReturn

Return type

Arrange<T, TReturn>(String, Type[], Object[])

Arranges a method for mocking.

Declaration
FuncExpectation<TReturn> Arrange<T, TReturn>(string memberName, Type[] typeArguments, params object[] args)
Parameters
System.String memberName

Target member name

System.Type[] typeArguments

Generic type arguments of the member specified by memberName

System.Object[] args

Method arguments. Use Expr for predefined argument matchers.

Returns
FuncExpectation<TReturn>

Type Parameters
T

Type of the target.

TReturn

Return type

ArrangeSet(Object, String, Object)

Arranges a non-public property setter for mocking.

Declaration
ActionExpectation ArrangeSet(object target, string propertyName, object value)
Parameters
System.Object target

Target instance

System.String propertyName

Property name

System.Object value

Property value. Use Expr for predefined argument matchers.

Returns
ActionExpectation

Reference to setup actions calls

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
System.Type type

Type that contains the non-public static property

System.String propertyName

Property name

System.Object value

Property value. Use Expr for predefined argument matchers.

Returns
ActionExpectation

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
System.String propertyName

Property name

System.Object value

Property value. Use Expr for predefined argument matchers.

Returns
ActionExpectation

Reference to setup actions calls

Type Parameters
T

Type that contains the non-public static property

Assert(Object, MethodInfo, Object[])

Asserts the specified method that it is called as expected.

Declaration
void Assert(object target, MethodInfo method, params object[] args)
Parameters
System.Object target

Target mock

System.Reflection.MethodInfo method

Method to assert taken from reflection.

System.Object[] args

Method arguments

Assert(Object, MethodInfo, Occurs, Object[])

Asserts the specified method that it is called as expected.

Declaration
void Assert(object target, MethodInfo method, Occurs occurs, params object[] args)
Parameters
System.Object target

Target mock

System.Reflection.MethodInfo method

Method to assert taken from reflection.

Occurs occurs

Specifies the number of times a call should occur.

System.Object[] args

Method arguments

Assert(Object, String, Object[])

Asserts the specified member that it is called as expected.

Declaration
void Assert(object target, string memberName, params object[] args)
Parameters
System.Object target

Target mock

System.String memberName

Name of the member

System.Object[] args

Method arguments

Assert(Object, String, Type[], Object[])

Asserts the specified member that it is called as expected.

Declaration
void Assert(object target, string memberName, Type[] typeArguments, params object[] args)
Parameters
System.Object target

Target mock

System.String memberName

Name of the member

System.Type[] typeArguments

Generic type arguments of the member specified by memberName

System.Object[] args

Method arguments

Assert(Object, String, Type[], Occurs, 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
System.Object target

Target mock

System.String memberName

Name of the member

System.Type[] typeArguments

Generic type arguments of the member specified by memberName

Occurs occurs

Specifies the number of times a call should occur.

System.Object[] args

Method arguments

Assert(Object, String, Occurs, Object[])

Asserts the specified member that it is called as expected.

Declaration
void Assert(object target, string memberName, Occurs occurs, params object[] args)
Parameters
System.Object target

Target mock

System.String memberName

Name of the member

Occurs occurs

Specifies the number of times a call should occur.

System.Object[] args

Method arguments

Assert(Object, 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
System.Object dynamicExpression

An expression built using a wrapper returned by Wrap.

Args args

Additional arguments to clarify the assertion expression.

Occurs occurs

Occurrence expectation to assert.

System.String message

A message to display if the assertion fails.

Assert(Object, Occurs, String)

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

Declaration
void Assert(dynamic dynamicExpression, Occurs occurs, string message = null)
Parameters
System.Object dynamicExpression

An expression built using a wrapper returned by Wrap.

Occurs occurs

Occurrence expectation to assert.

System.String message

A message to display if the assertion fails.

Assert(MethodBase, Object[])

Asserts the specified method that it is called as expected.

Declaration
void Assert(MethodBase method, params object[] args)
Parameters
System.Reflection.MethodBase method

Target method

System.Object[] args

Method arguments

Assert(MethodBase, Occurs, Object[])

Asserts the specified method that it is called as expected.

Declaration
void Assert(MethodBase method, Occurs occurs, params object[] args)
Parameters
System.Reflection.MethodBase method

Target method

Occurs occurs

Specifies the number of times a call should occur.

System.Object[] args

Method arguments

Assert(Type, String, Object[])

Asserts the specified member that it is called as expected.

Declaration
void Assert(Type targetType, string memberName, params object[] args)
Parameters
System.Type targetType

Type of the target

System.String memberName

Name of the member

System.Object[] args

Method arguments

Assert(Type, String, Type[], Object[])

Asserts the specified member that it is called as expected.

Declaration
void Assert(Type targetType, string memberName, Type[] typeArguments, params object[] args)
Parameters
System.Type targetType

Type of the target

System.String memberName

Name of the member

System.Type[] typeArguments

Generic type arguments of the member specified by memberName

System.Object[] args

Method arguments

Assert(Type, String, Type[], Occurs, 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
System.Type targetType

Type of the target

System.String memberName

Name of the member

System.Type[] typeArguments

Generic type arguments of the member specified by memberName

Occurs occurs

Specifies the number of times a call should occur.

System.Object[] args

Method arguments

Assert(Type, String, Occurs, Object[])

Asserts the specified member that it is called as expected.

Declaration
void Assert(Type targetType, string memberName, Occurs occurs, params object[] args)
Parameters
System.Type targetType

Type of the target

System.String memberName

Name of the member

Occurs occurs

Specifies the number of times a call should occur.

System.Object[] args

Method arguments

Assert<TReturn>(Object, String, Object[])

Asserts the specified member that it is called as expected.

Declaration
void Assert<TReturn>(object target, string memberName, params object[] args)
Parameters
System.Object target

Target mock

System.String memberName

Name of the member

System.Object[] args

Method arguments

Type Parameters
TReturn

Return type of the method

Assert<TReturn>(Object, String, Type[], Object[])

Asserts the specified member that it is called as expected.

Declaration
void Assert<TReturn>(object target, string memberName, Type[] typeArguments, params object[] args)
Parameters
System.Object target

Target mock

System.String memberName

Name of the member

System.Type[] typeArguments

System.Object[] args

Method arguments

Type Parameters
TReturn

Return type of the method

Assert<TReturn>(Object, String, Type[], Occurs, 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
System.Object target

Target mock

System.String memberName

Name of the member

System.Type[] typeArguments

Generic type arguments of the member specified by memberName

Occurs occurs

Specifies the number of times a call should occur.

System.Object[] args

Method arguments

Type Parameters
TReturn

Return type of the method

Assert<TReturn>(Object, String, Occurs, Object[])

Asserts the specified member that it is called as expected.

Declaration
void Assert<TReturn>(object target, string memberName, Occurs occurs, params object[] args)
Parameters
System.Object target

Target mock

System.String memberName

Name of the member

Occurs occurs

Specifies the number of times a call should occur.

System.Object[] args

Method arguments

Type Parameters
TReturn

Return type of the method

Assert<T>(String, Object[])

Asserts the specified member that it is called as expected.

Declaration
void Assert<T>(string memberName, params object[] args)
Parameters
System.String memberName

Name of the member

System.Object[] args

Method arguments

Type Parameters
T

Specify the target type

Assert<T>(String, Type[], Object[])

Asserts the specified member that it is called as expected.

Declaration
void Assert<T>(string memberName, Type[] typeArguments, params object[] args)
Parameters
System.String memberName

Name of the member

System.Type[] typeArguments

Generic type arguments of the member specified by memberName

System.Object[] args

Method arguments

Type Parameters
T

Specify the target type

Assert<T>(String, Type[], Occurs, 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
System.String memberName

Name of the member

System.Type[] typeArguments

Generic type arguments of the member specified by memberName

Occurs occurs

Specifies the number of times a call should occur.

System.Object[] args

Method arguments

Type Parameters
T

Specify the target type

Assert<T>(String, Occurs, Object[])

Asserts the specified member that it is called as expected.

Declaration
void Assert<T>(string memberName, Occurs occurs, params object[] args)
Parameters
System.String memberName

Name of the member

Occurs occurs

Specifies the number of times a call should occur.

System.Object[] args

Method arguments

Type Parameters
T

Specify the target type

Assert<TReturn>(Type, String, Object[])

Asserts the specified member that it is called as expected.

Declaration
void Assert<TReturn>(Type targetType, string memberName, params object[] args)
Parameters
System.Type targetType

Type of the target

System.String memberName

Name of the member

System.Object[] args

Method arguments

Type Parameters
TReturn

Specify the return type method

Assert<TReturn>(Type, String, Type[], 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
System.Type targetType

Type of the target

System.String memberName

Name of the member

System.Type[] typeArguments

Generic type arguments of the member specified by memberName

System.Object[] args

Method arguments

Type Parameters
TReturn

Specify the return type method

Assert<TReturn>(Type, String, Type[], Occurs, 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
System.Type targetType

Type of the target

System.String memberName

Name of the member

System.Type[] typeArguments

Generic type arguments of the member specified by memberName

Occurs occurs

Specifies the number of times a call should occur.

System.Object[] args

Method arguments

Type Parameters
TReturn

Assert<TReturn>(Type, String, Occurs, 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
System.Type targetType

Type of the target

System.String memberName

Name of the member

Occurs occurs

Specifies the number of times a call should occur.

System.Object[] args

Method arguments

Type Parameters
TReturn

Assert<T, TReturn>(String, Object[])

Asserts the specified member that it is called as expected.

Declaration
void Assert<T, TReturn>(string memberName, params object[] args)
Parameters
System.String memberName

Name of the member

System.Object[] args

Method arguments

Type Parameters
T

Specify the target type

TReturn

Specify the return type for the method

Assert<T, TReturn>(String, Type[], Object[])

Asserts the specified member that it is called as expected.

Declaration
void Assert<T, TReturn>(string memberName, Type[] typeArguments, params object[] args)
Parameters
System.String memberName

Name of the member

System.Type[] typeArguments

Generic type arguments of the member specified by memberName

System.Object[] args

Method arguments

Type Parameters
T

Specify the target type

TReturn

Specify the return type for the method

Assert<T, TReturn>(String, Type[], Occurs, 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
System.String memberName

Name of the member

System.Type[] typeArguments

Generic type arguments of the member specified by memberName

Occurs occurs

Specifies the number of times a call should occur.

System.Object[] args

Method arguments

Type Parameters
T

Specify the target type

TReturn

Specify the return type for the method

Assert<T, TReturn>(String, Occurs, Object[])

Asserts the specified member that it is called as expected.

Declaration
void Assert<T, TReturn>(string memberName, Occurs occurs, params object[] args)
Parameters
System.String memberName

Name of the member

Occurs occurs

Specifies the number of times a call should occur.

System.Object[] args

Method arguments

Type Parameters
T

Specify the target type

TReturn

Specify the return type for the method

GetTimesCalled(Object, MethodInfo, Object[])

Returns the number of times the specified member was called.

Declaration
int GetTimesCalled(object target, MethodInfo method, params object[] args)
Parameters
System.Object target

Target mock

System.Reflection.MethodInfo method

Method taken from reflection

System.Object[] args

Method arguments

Returns
System.Int32

Number of calls.

GetTimesCalled(Object, String, Object[])

Returns the number of times the specified member was called.

Declaration
int GetTimesCalled(object target, string memberName, params object[] args)
Parameters
System.Object target

Target mock

System.String memberName

Name of the member

System.Object[] args

Method arguments

Returns
System.Int32

Number of calls.

GetTimesCalled(Object, String, Type[], Object[])

Returns the number of times the specified member was called.

Declaration
int GetTimesCalled(object target, string memberName, Type[] typeArguments, params object[] args)
Parameters
System.Object target

Target mock

System.String memberName

Name of the member

System.Type[] typeArguments

Generic type arguments of the member specified by memberName

System.Object[] args

Method arguments

Returns
System.Int32

Number of calls.

GetTimesCalled(MethodBase, Object[])

Returns the number of times the specified member was called.

Declaration
int GetTimesCalled(MethodBase method, params object[] args)
Parameters
System.Reflection.MethodBase method

Target method

System.Object[] args

Method arguments

Returns
System.Int32

Number of calls.

GetTimesCalled(Type, String, Object[])

Returns the number of times the specified member was called.

Declaration
int GetTimesCalled(Type type, string memberName, params object[] args)
Parameters
System.Type type

Type of the target

System.String memberName

Name of the member

System.Object[] args

Method arguments

Returns
System.Int32

Number of calls.

GetTimesCalled(Type, String, Type[], Object[])

Returns the number of times the specified member was called.

Declaration
int GetTimesCalled(Type type, string memberName, Type[] typeArguments, params object[] args)
Parameters
System.Type type

Type of the target

System.String memberName

Name of the member

System.Type[] typeArguments

Generic type arguments of the member specified by memberName

System.Object[] args

Method arguments

Returns
System.Int32

Number of calls.

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
System.Object instance

Instance to which non-public access will be given.

Returns
PrivateAccessor

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
System.Type type

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

Returns
PrivateAccessor

Non-public accessor.

Raise(Object, EventInfo, 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.

Declaration
void Raise(object instance, EventInfo eventInfo, params object[] args)
Parameters
System.Object instance

Instance on which to raise the event.

System.Reflection.EventInfo eventInfo

The event to raise.

System.Object[] args

Arguments to pass to the event handlers.

Raise(Object, String, 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.

Declaration
void Raise(object instance, string eventName, params object[] args)
Parameters
System.Object instance

Instance on which to raise the event.

System.String eventName

The name of event to raise.

System.Object[] args

Arguments to pass to the event handlers.

Raise(EventInfo, 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.

Declaration
void Raise(EventInfo eventInfo, params object[] args)
Parameters
System.Reflection.EventInfo eventInfo

The event to raise.

System.Object[] args

Arguments to pass to the event handlers.

Raise(Type, String, 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.

Declaration
void Raise(Type type, string eventName, params object[] args)
Parameters
System.Type type

The type on which the event is declared.

System.String eventName

The name of event to raise.

System.Object[] args

Arguments to pass to the event handlers.

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
System.Object instance

The object to wrap.

Returns
System.Object

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
System.Type type

The type to wrap.

Returns
System.Object

A wrapper that can be passed to Arrange.

Extension Methods

FluentHelper.Arrange<T, TResult>(T, Expression<Func<T, TResult>>)
FluentHelper.Arrange<T>(T, Expression<Action<T>>)
FluentHelper.ArrangeSet<T>(T, Action<T>)
FluentHelper.ArrangeLike<T>(T, Expression<Func<T, Boolean>>)
FluentHelper.Assert<T, TReturn>(T, Expression<Func<T, TReturn>>, String)
FluentHelper.Assert<T, TReturn>(T, Expression<Func<T, TReturn>>, Occurs, String)
FluentHelper.Assert<T>(T, Expression<Action<T>>, String)
FluentHelper.Assert<T>(T, Expression<Action<T>>, Occurs, String)
FluentHelper.AssertSet<T>(T, Action<T>, String)
FluentHelper.AssertSet<T>(T, Action<T>, Occurs, String)
FluentHelper.Raise<T>(T, Action<T>, EventArgs)
FluentHelper.Raise<T>(T, Action<T>, Object[])
FluentHelper.Assert<T>(T, String)
FluentHelper.AssertAll<T>(T, String)
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.