Overloaded. Fake a future instance of type.
Namespace: TypeMock.ArrangeActAssert.Fluent
Assembly: Typemock.ArrangeActAssert (in Typemock.ArrangeActAssert.dll) Version: 9.4.1.0 (9.4.1.0)
Syntax
Parameters
- type
- Type: SystemType
The type of the fake instance to be created. - 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.
Return Value
Type: ObjectAn object of type type which is used as a faking handle.
Examples
[TestMethod] [Isolated] public void FakeAFutureInstance_StubIncrementMethod() { bool flag = false; RealLogger fake = Isolate.NonPublic.Fake.NextInstance(typeof(RealLogger), Members.ReturnRecursiveFakes, context => flag = true); // This object is swapped with the fake RealLogger logger = new RealLogger(); Assert.IsTrue(flag); }
See Also