johnildergleidisson
johnildergleidisson

Reputation: 2117

FakeItEasy - How to have an interface fake inherit from abstract?

I have an interface

interface IInterface {}

An abstract class

abstract class AbstractClass : IInterface { }

Concrete class

class Irrelevant { Irrelevant (IInterface service) {} }

I'm writing a unit test against Irrelevant and the abstract class already contains helpful methods I'd want to leverage for my unit test. How would I make my A.Fake<IInterface>(); inherit from AbstractClass?

Upvotes: 2

Views: 1717

Answers (1)

Blair Conrad
Blair Conrad

Reputation: 241790

var fake = A.Fake<AbstractClass>();

That's how FakeItEasy makes fakes - by having DynamicProxy subclass an existing class. (When an interface is faked, it subclasses System.Object.)

Upvotes: 5

Related Questions