I have written a custom policy in FluentSecurity (implement ISecurityPolicy
) and a corresponding PolicyViolationHandler by implementing IPolicyViolationHandler
. Everything is working perfectly with the policy and the handler, however I'm doing some back-filling by writing some unit tests to test my implementation of IPolicyViolationHandler.Handle(PolicyViolationException exception)
.
I know I'm doing it backwards writing the test after the implementation (admission to avoid flames).
My question is: Is there a way to generate a PolicyViolationException
object as a mock that I can pass in for my test? PolicyViolationException doesn't have any public constructors (so I can't new an object), nor an abstract base, or interface to mock against (using Moq).
I took a look through the API but didn't see anything to generate one. I know I could do some reflection magic to get one, but wanted to check if I was missing something.