private void SetupPostRegister() { var accountService = new Mock<IAccountService>(); accountService.Setup(acct => acct.SaveUser(new User())).Returns(new User()); _accountController = new AccountsController(new BaseServiceCollection(accountService.Object, null, null)); _accountController.ControllerContext = new ControllerContext { Controller = _accountController, RequestContext = RequestContext }; }
private void SetupXmlGetSearchUsersByName() { var service = new Mock<IAccountService>(); var mockRequest = new Mock<HttpRequestBase>(); var httpContext = new Mock<HttpContextBase>(); service.Setup(x => x.FindUsers(It.IsAny<UsersSearchCriteria>())).Returns(new List<User>()); _accountController = new AccountsController(new BaseServiceCollection(service.Object, null, null)); mockRequest.SetupGet(x => x.Headers).Returns(new WebHeaderCollection { { "X-Requested-With", "XMLHttpRequest" } }); httpContext.SetupGet(x => x.Request).Returns(mockRequest.Object); _accountController.ControllerContext = new ControllerContext(httpContext.Object, new RouteData(), _accountController); }
private void SetupPostLogOut() { _accountController = new AccountsController(null); var httpContext = new MockHttpContextBase { User = new MockUser { Identity = new MockIdentity("", "", false) } }; var controllerContext = new ControllerContext(httpContext, new RouteData(), new BaseController(null)); _accountController = new AccountsController(null) { ControllerContext = controllerContext }; }
private void SetupPostLogInSuccess() { var authenicationService = new Mock<IAuthenticationService>(); authenicationService.Setup(x => x.ValidateUser(ValidAccountLogInModel.EmailAddress, HashString(ValidAccountLogInModel.Password))).Returns(true); var httpContext = new MockHttpContextBase { User = new MockUser { Identity = new MockIdentity("", "", false) } }; var controllerContext = new ControllerContext(httpContext, new RouteData(), new BaseController(null)); var accountService = new Mock<IAccountService>(); accountService.Setup(x => x.GetUserByEmailAddress(It.IsAny<string>())).Returns<User>(null); _accountController = new AccountsController(new BaseServiceCollection(accountService.Object, null, authenicationService.Object)) { ControllerContext = controllerContext }; }
private void SetupGetRegister() { _accountController = new AccountsController(null); }
private void SetupGetLogInForNonAuthenticatedUser() { _accountController = new AccountsController(null); }
private void SetupGetLogInForAuthenticatedUser() { var mockUser = new MockUser { Identity = new MockIdentity("", "", true) }; var mockHttpContext = new MockHttpContextBase { User = mockUser }; var controllerContext = new ControllerContext { HttpContext = mockHttpContext }; var accountService = new Mock<IAccountService>(); accountService.Setup(x => x.GetUserByEmailAddress(It.IsAny<string>())).Returns(new User()); var baseServiceCollection = new BaseServiceCollection(accountService.Object, null, null); _accountController = new AccountsController(baseServiceCollection) { ControllerContext = controllerContext }; }