I am using the Captcha class from commonlibrary (http://commonlibrarynet.codeplex.com/). My code works and everything but now I'm trying to write the unit test.
My validation rule is:
RuleFor(x => x.CaptchaUserInput)
.NotEmpty()
.Must((x, captchaUserInput) => Captcha.IsCorrect(captchaUserInput, x.CaptchaGeneratedText))
.WithMessage("Invalid captcha code");
In my set up code I tried to do the following:
A.CallTo(() => Captcha.IsCorrect()).Returns(true);
but I get the following error message:
SetUp : FakeItEasy.Configuration.FakeConfigurationException :
The current proxy generator can not intercept the specified method for the following reason:
- Static methods can not be intercepted.
at FakeItEasy.Configuration.DefaultInterceptionAsserter.AssertThatMethodCanBeInterceptedOnInstance(Metho dInfo method, Object callTarget)
at FakeItEasy.Configuration.FakeConfigurationManager.CallTo(Expression`1 callSpecification)
at ProdMaster.Hosts.Web.Tests.Unit.Controllers.AccountControllerTests.SetUp() in AccountControllerTests.cs: line 44
So the question really is how to fake static methods using FakeItEasy.
TIA,
David