Overloaded. Fakes all instances of type T, and allows to add code to run before the constructor.
Namespace: TypeMock.ArrangeActAssert.Fluent
Assembly: Typemock.ArrangeActAssert (in Typemock.ArrangeActAssert.dll) Version: 9.4.1.0 (9.4.1.0)
Syntax
Parameters
- behavior
- Type: TypeMock.ArrangeActAssertMembers
Can be one of the following values:Members Value Description Members.MustSpecifyReturnValues All void calls are ignored. Unless using WhenCalled(Action) on methods that return values and properties, they will throw a TypeMockException. Members.ReturnNulls All void calls are ignored. Unless using WhenCalled(Action) on methods that return values and properties, they will return null values (or zero for value types). Members.CallOriginal All methods are called. Use WhenCalled(Action) to change this behavior. Members.ReturnRecursiveFakes Default. All void calls are ignored. When calling the fake's methods returning values or properties, they will return a fake value, which presents this behavior recursively. Any deep call will never return a Null value. - doInstead
- Type: SystemActionMethodCallContext
The action to run at the start of the constructor.
Type Parameters
- T
- The type of the fake instance to be created.
Return Value
Type: TAn object of type T which is used as a faking handle.
Examples
[TestMethod] [Isolated] public void FakeAllInstances_StubIncrementMethod() { bool flag = false; RealLogger fake = Isolate.Fake.AllInstances<RealLogger>(context => flag = true); // This object is swapped with the fake RealLogger logger = new RealLogger(); Assert.IsTrue(flag); }
See Also