Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Oct 20, 2025. It is now read-only.

philippdolder/EnableFaking.Fody

Open more actions menu

Repository files navigation

This is an add-in for Fody

Icon

Introduction to Fody

Change class members to virtual as part of your build to help making TDD less effort.

Now you ask:

There is Virtuosity already. Why would I use EnableFaking instead?"

The answer:

EnableFaking intends to only make those types fakeable (make members virtual) that you otherwise would need to define an interface solely to be able to use the type with a fake framework like Fake It Easy.

Instead of

    public class MyImplementation : IMyInterface
    {
        public void MyMethod()
        {
        }
    }
    
    public interface IMyInterface
    {
        void MyMethod();
    }

you only have to write

    public class MyImplementation
    {
        public void MyMethod()
        {
        }
    }

and all other classes remain untouched.

Nuget package

There is a nuget package available here http://nuget.org/packages/EnableFaking.Fody

What does it do?

Selects all classes meeting the following criteria

  • public
  • not a container (has only constructors and properties)
  • not implementing any interfaces (I suggest faking the interfaces in these cases instead of the class)
  • not sealed
  • not nested

Selects all members from the selected types that are

  • public
  • not static
  • not virtual
  • not a constructor

and changes them to virtual.

All calls to the now virtual members are changed to virtual calls.

If EnableFaking does not virtualize a public class you can add a DoVirtualizeAttribute on your class.

Define the attribute anywhere in your code (your code does not have a dependency to EnableFaking)

    [AttributeUsage(AttributeTargets.Class)]
    public class DoVirtualizeAttribute : Attribute
    {
    }

Add it to the class you want to be virtualized

    [DoVirtualize]
    public class YourClass
    {
    }

About

Fody AddIn that allows faking your types without writing interfaces for testing purposes only

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Morty Proxy This is a proxified and sanitized view of the page, visit original site.