Isolate.WhenCalled Method (Action) Isolate.WhenCalled Method (Action) Isolate.WhenCalled Method (Action) Isolate.WhenCalled Method (Action) Isolate.WhenCalled Method (Action) Isolate.WhenCalled Method (Action) Isolate.WhenCalled Method (Action) Isolate.WhenCalled Method (Action) Isolate.WhenCalled Method (Action) Isolate.WhenCalled Method (Action) Isolate.WhenCalled Method (Action) Isolate.WhenCalled Method (Action) Isolate.WhenCalled Method (Action) Isolate.WhenCalled Method (Action) Isolate.WhenCalled Method (Action) Isolate.WhenCalled Method (Action) Isolate.WhenCalled Method (Action) Isolate.WhenCalled Method (Action) Isolate.WhenCalled Method (Action) Isolate.WhenCalled Method (Action) Isolate.WhenCalled Method (Action) Isolate.WhenCalled Method (Action)

IsolateWhenCalled Method (Action)

Typemock Isolator Developer Guide
Accepts a method in the form of a Lambda expression, to set a specific behavior on it.

Namespace:  TypeMock.ArrangeActAssert
Assembly:  Typemock.ArrangeActAssert (in Typemock.ArrangeActAssert.dll) Version: 9.1.4.0 (9.1.4.0)
Syntax

public static IPublicVoidActionHandler WhenCalled(
	Action action
)

Parameters

action
Type: SystemAction
An Action in a form of a Lambda expression (with no parameters) that expresses the method we want to set a behavior on.

Return Value

Type: IPublicVoidActionHandler
A interface reference.
Remarks

Because of the nature of fluent interface, WhenCalled should be used with its proceeding methods.
Examples

Here is an example how to use WhenCalled in order to ignore (stub) a call:
[TestMethod]
[Isolated]
public void FakeAnInstance_StubIncrementMethod()
{
    RealLogger fake = Isolate.Fake.Instance<RealLogger>();

    // Increment call will be ignored (stubbed)
    Isolate.WhenCalled(() => fake.Increment()).IgnoreCall();

    // Make sure Count is reset
    fake.Count = 0;

    // This call is faked - count should not increment
    fake.Increment();

    Assert.AreEqual(0, fake.Count);
}
See Also

Reference