Faking an Instance
Method |
Description |
SealedClass fake =
Isolate.Fake.Instance<SealedClass>(); |
Creates fake instances (can be used on interfaces, abstract, concrete and sealed types). |
SealedClass fake =
Isolate.Swap.NextInstance<SealedClass>(). |
Fakes a future instance. |
Isolate.Fake.AllInstances |
Fakes all Instances. |
UnderTest real =
Isolate.Fake.Dependencies<UnderTest>([args]) |
Fakes all dependencies of a type. |
Isolate.Fake.Instance<Derived>(Members.ReturnRecursiveFakes, ConstructorWillBe.Called); |
Fakes all methods except the constructor. |
Isolate.Fake.Instance<Derived>(Members.CallOriginal, ConstructorWillBe.Called, BaseConstructorWillBe.Ignored); |
Calls the original method and ignores the constructor. |
Isolate.Fake.Instance<Derived>(Members.CallOriginal, ConstructorWillBe.Called, BaseConstructorWillBe.Ignored); |
Ignores the base class constructor. |
Isolate.Fake.StaticConstructor<Dependency>(); |
Fakes a static constructor. |
var handle =Isolate.Fake.NextInstance<Dependency>(Members.ReturnRecursiveFakes, context=> { // action here }); |
Runs a custom logic. |
Isolate.Swap.NextInstance<Dependency>() .ConstructorWillThrow(new OutOfMemoryException()); |
Fakes an error in a constructor. |