commonlibrary(http://commonlibrarynet.codeplex.com/)のCaptchaクラスを使用しています。私のコードはすべて機能しますが、今は単体テストを作成しようとしています。
私の検証ルールは次のとおりです。
RuleFor(x => x.CaptchaUserInput)
.NotEmpty()
.Must((x, captchaUserInput) => Captcha.IsCorrect(captchaUserInput, x.CaptchaGeneratedText))
.WithMessage("Invalid captcha code");
私のセットアップコードでは、次のことを試みました。
A.CallTo(() => Captcha.IsCorrect()).Returns(true);
しかし、次のエラーメッセージが表示されます。
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
したがって、問題は、FakeItEasyを使用して静的メソッドを偽造する方法です。
TIA、
デビッド