Invoking Local Functions

To invoke local functions, use Isolate.Invoke.LocalFunction().

When to Use

You can invoke local functions when your test requires a local function to be called.

Syntax

C#

Instance:
Isolate.Invoke.LocalFunction(<instance>, "<method_name>", "<localFunction_name>", <list_of_arguments>);

Static:
Isolate.Invoke.LocalFunction<type>("method-name", "<localFunction_name>",  list-of-args);

Samples

Sample 1: Invoking an Instance Local Function

The following sample shows how to invoke an instance local function. Argument which is passed to the local function from Isolate.Invoke.LocalFunction() is 5.

C#

[TestMethod, Isolated]
public void InvokeLocalFunction()
{
  var underTest = new ClassWithLocal();
  var result = Isolate.Invoke.LocalFunction(underTest, "UseLocalFunc", "GetLocal", 5);
  Assert.AreEqual(5, result);
}

Sample 2: Invoking a Static Local Function

The following sample shows how to invoke a static local function with a static defining method. Argument which is passed to the local function from Isolate.Invoke.LocalFunction() is 5.

C#

[TestMethod, Isolated]
public void InvokeStaticLocalFunction()
{
  var result = Isolate.Invoke.LocalFunction<ClassWithLocal>("UseStaticLocalFunc", "GetLocal", 5);
  Assert.AreEqual(5, result);
}