Is it possible to mock the static FormsAuthentication? I would like to check that the SignIn and SignOut methods are called in an MVC LoginController.
I have a mocked LoginController, lc, and the following code:
If I run this under debug it passes but if I just run it I get:
I have a mocked LoginController, lc, and the following code:
Mock.SetupStatic(typeof(FormsAuthentication));
Mock.Arrange(() => FormsAuthentication.SignOut()).OccursOnce();
var result = lc.Logoff();
Mock.Assert(() => FormsAuthentication.SignOut());
If I run this under debug it passes but if I just run it I get:
Test Name: LogoffShouldCallFormsAuthenticationSignOut
Test FullName: OfDisplays.WebTests.SecurityTests.LogoffShouldCallFormsAuthenticationSignOut
Test Source: c:\SoftDev\Projects\OFDisplays\OfDisplays.Web\OfDisplays.WebTests\SecurityTests.cs : line 83
Test Outcome: Failed
Test Duration: 0:00:01.9634171
Result Message:
Test method OfDisplays.WebTests.SecurityTests.LogoffShouldCallFormsAuthenticationSignOut threw exception:
System.IO.FileNotFoundException: Could not load file or assembly 'Telerik.CodeWeaver.Api, Version=1.0.0.0, Culture=neutral, PublicKeyToken=87210992829a189d' or one of its dependencies. The system cannot find the file specified.WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
Result StackTrace:
at System.Web.Security.FormsAuthentication.SignOut()
at OfDisplays.Web.Controllers.LoginController.Logoff() in c:\SoftDev\Projects\OFDisplays\OfDisplays.Web\OfDisplays.Web\Controllers\LoginController.cs:line 57
at OfDisplays.WebTests.SecurityTests.LogoffShouldCallFormsAuthenticationSignOut() in c:\SoftDev\Projects\OFDisplays\OfDisplays.Web\OfDisplays.WebTests\SecurityTests.cs:line 90