This is an add-in for 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.
There is a nuget package available here http://nuget.org/packages/EnableFaking.Fody
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
public
- not
static
- not
virtual
- not a
constructor
and changes them to virtual
.
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
{
}