Sets behavior for a specific method on a an object
Namespace: TypeMock.ArrangeActAssert.Fluent
Assembly: Typemock.ArrangeActAssert (in Typemock.ArrangeActAssert.dll) Version: 9.4.1.0 (9.4.1.0)
Syntax
Parameters
- targetObject
- Type: SystemObject
The object to set method behavior on. - methodName
- Type: SystemString
The name of a method to set behavior on.
Return Value
Type: INonPublicMethodHandlerAn interface reference.
Remarks
Examples
[TestMethod] [Isolated] public void StubPrivateMethod_DoNotWriteToDisk() { RealLogger fake = Isolate.NonPublic.Fake.Instance(typeof(RealLogger)); // Avoid performing actual write to disk by ignoring (stubbing) a private call Isolate.NonPublic.WhenCalled(fake, "WriteToDisk").IgnoreCall(); // The private call is stubbed so no actual disk writes are performed fake.Log("Hello World"); Assert.AreEqual(1, fake.LineCount); }
See Also