Hi, I am doing a few unit test in my ASP.Net MVC2 project. I use the Moq framework. In my LogOnController,
[HttpPost] public ActionResult LogOn(LogOnModel model, string returnUrl = "") { FormsAuthenticationService FormsService = new FormsAuthenticationService(); FormsService.SignIn(model.UserName, model.RememberMe); }
In class FormAuthenticationService
public class FormsAuthenticationService : IFormsAuthenticationService { public virtual void SignIn(string userName, bool createPersistentCookie) { if (String.IsNullOrEmpty(userName)) throw new ArgumentException("Value cannot be null or empty.", "userName"); FormsAuthentication.SetAuthCookie(userName, createPersistentCookie); } public void SignOut() { FormsAuthentication.SignOut(); } }
My problem is how can I avoid execution
FormsService.SignIn(model.UserName, model.RememberMe);
this line. Or is there any way to moq
FormsService.SignIn(model.UserName, model.RememberMe);
using a Moq frame without modifying my ASP.Net MVC2 project.
Dilma
source share