How do I mock a class without an interface?

Simply mark any method you need to fake as virtual (and not private). Then you will be able to create a fake that can override the method.

If you use new Mock<Type> and you don’t have a parameterless constructor then you can pass the parameters as the arguments of the above call as it takes a type of param Objects

Leave a Comment