Sure:
internal interface IFoo { void Bar(); void Baz(); void Bat(); } internal class Foo { private IFoo FooImplementation = new DisabledFoo()
And if you intend to mock the foo implementation for unit testing, just let go of the FooIsEnabled property and make FooImplementation public. In this case, you should also get rid of DisabledFoo and test with an instance, for example:
var fooImplementationMock = new Mock<IFoo>(); var foo = new Foo { FooImplementation = fooImplementationMock.Object }; foo.Bar(); fooImplementationMock.Verify(f => f.Bar());
if you use moq .
source share