public void SetUp() { User = new User { Email = "ValidEmail", Password = "******", ShoppingCart = null, UserProfile = new UserProfile { Address = "Address", City = "City", Country = "Country", FirstName = "FirstName", LastName = "LastName", PostalCode = "PostalCode" } }; _shoppingCartService = new FakeShoppingCartService(); _userRepository = new FakeUserRepository(); _checkOutController = new CheckOutController(_shoppingCartService, _userRepository); var controllerContext = new Mock<ControllerContext>(); controllerContext.SetupGet(x => x.HttpContext.User.Identity.Name) .Returns(User.Email); _checkOutController.ControllerContext = controllerContext.Object; }
public void SetUp() { _shoppingCartService = new FakeShoppingCartService(); _authenticationService = new FakeAuthenticationService(); _personalizationService = new FakePersonalizationService(); _userRepository = new FakeUserRepository(); _fakeAuthorizationService = new FakeAuthorizationService(); _accountController = new AccountController(_shoppingCartService, _authenticationService, _personalizationService, _userRepository, _fakeAuthorizationService); var controllerContext = new Mock<ControllerContext>(); controllerContext.SetupGet(x => x.HttpContext.User.Identity.Name) .Returns(_authenticationService.User.Email); // controllerContext.SetupGet(x => x.HttpContext.User.Identity.IsAuthenticated) // .Returns(true); // controllerContext.SetupGet(x => x.HttpContext.Request.IsAuthenticated) // .Returns(true); controllerContext.SetupGet(x => x.HttpContext.Session[ShoppingCartService.CartSessionKey]) .Returns(_authenticationService.User.ShoppingCart); _accountController.ControllerContext = controllerContext.Object; var context = new Mock<HttpContextBase>(MockBehavior.Default); _accountController.Url = new UrlHelper( new RequestContext(context.Object, new RouteData()), new RouteCollection()); }