public void Before_each_test()
        {
            // Arrange

            _repository = new InMemoryRepository(true);
            _authenticationService = new MockFormsAuthenticationService();
            _membershipService = new MockMembershipService();
            _currentUser = new MockCurrentUserService();

            _accountController = new AccountController(_repository, _currentUser, _authenticationService, _membershipService);
        }
Beispiel #2
0
        private static AccountController GetAccountController()
        {
            IFormsAuthentication     formsAuth          = new MockFormsAuthenticationService();
            MembershipProvider       membershipProvider = new MockMembershipProvider();
            AccountMembershipService membershipService  = new AccountMembershipService(membershipProvider);
            AccountController        controller         = new AccountController(formsAuth, membershipService);
            ControllerContext        controllerContext  = new ControllerContext(new MockHttpContext(), new RouteData(), controller);

            controller.ControllerContext = controllerContext;
            return(controller);
        }
        public void Before_each_test()
        {
            // Arrange

            _repository            = new InMemoryRepository(true);
            _authenticationService = new MockFormsAuthenticationService();
            _membershipService     = new MockMembershipService();
            _currentUser           = new MockCurrentUserService();

            _accountController = new AccountController(_repository, _currentUser, _authenticationService, _membershipService);
        }
Beispiel #4
0
        private static AccountController GetAccountController()
        {
            IFormsAuthentication formsAuth          = new MockFormsAuthenticationService();
            MembershipProvider   membershipProvider = new MockMembershipProvider();
            var membershipService = new AccountMembershipService(membershipProvider);
            var controller        = new AccountController(formsAuth, new CommandServiceClient(), new MembershipReadModel());

            var controllerContext = new ControllerContext(new MockHttpContext(), new RouteData(), controller);

            controller.ControllerContext = controllerContext;
            return(controller);
        }
        private static AccountController GetAccountController()
        {
            IFormsAuthentication     formsAuth          = new MockFormsAuthenticationService();
            MembershipProvider       membershipProvider = new MockMembershipProvider();
            AccountMembershipService membershipService  = new AccountMembershipService(membershipProvider, null);
            var modRepo = new FakeModuleRepository();
            AccountController controller        = new AccountController(modRepo, formsAuth, membershipService);
            ControllerContext controllerContext = new ControllerContext(new MockHttpContext(), new RouteData(), controller);

            controller.ControllerContext = controllerContext;
            return(controller);
        }
Beispiel #6
0
        public void ConstructorSetsProperties()
        {
            // Arrange
            IFormsAuthentication formsAuth         = new MockFormsAuthenticationService();
            IMembershipService   membershipService = new AccountMembershipService();

            // Act
            AccountController controller = new AccountController(formsAuth, membershipService);

            // Assert
            Assert.AreEqual(formsAuth, controller.FormsAuth, "FormsAuth property did not match.");
            Assert.AreEqual(membershipService, controller.MembershipService, "MembershipService property did not match.");
        }
Beispiel #7
0
        private static AccountController GetAccountController()
        {
            IFormsAuthentication     formsAuth          = new MockFormsAuthenticationService();
            MembershipProvider       membershipProvider = new MockMembershipProvider();
            AccountMembershipService membershipService  = new AccountMembershipService(membershipProvider);
            AccountController        controller         = new AccountController(formsAuth, membershipService);

            HttpContextBase contextBase = MvcMockHelpers.FakeHttpContext(); // new MockHttpContext();

            controller.ControllerContext = new ControllerContext(contextBase, new RouteData(), controller);
            controller.Url = new UrlHelper(new RequestContext(contextBase, new RouteData()), new RouteCollection());
            return(controller);
        }
Beispiel #8
0
        public void ConstructorSetsProperties()
        {
            // Arrange
            IFormsAuthentication formsAuth = new MockFormsAuthenticationService();
            var membershipReadModel        = new MembershipReadModel();

            // Act
            var controller = new AccountController(formsAuth, new CommandServiceClient(), membershipReadModel);

            // Assert
            Assert.AreEqual(formsAuth, controller.FormsAuth, "FormsAuth property did not match.");
            Assert.AreEqual(membershipReadModel, controller.MembershipReadModel,
                            "MembershipReadModel property did not match.");
        }
Beispiel #9
0
        public void LogOff_LogsOutAndRedirects()
        {
            // Arrange
            AccountController controller       = GetAccountController();
            MockFormsAuthenticationService fas = new MockFormsAuthenticationService();

            fas.SignIn("goodEmail", false);
            Assert.AreEqual(true, fas.SignIn_WasCalled);

            // Act
            ////ActionResult result = controller.LogOff();
            fas.SignOut();

            // Assert
            // Assert.IsInstanceOf(typeof(RedirectToRouteResult), result);

            // RedirectToRouteResult redirectResult = (RedirectToRouteResult)result;
            // Assert.AreEqual("Home", redirectResult.RouteValues["controller"]);
            // Assert.AreEqual("Index", redirectResult.RouteValues["action"]);
            Assert.IsTrue(fas.SignOut_WasCalled);
        }
 private static AccountController GetAccountController()
 {
     IFormsAuthentication formsAuth = new MockFormsAuthenticationService();
     MembershipProvider membershipProvider = new MockMembershipProvider();
     AccountMembershipService membershipService = new AccountMembershipService(membershipProvider);
     AccountController controller = new AccountController(formsAuth, membershipService);
     ControllerContext controllerContext = new ControllerContext(new MockHttpContext(), new RouteData(), controller);
     controller.ControllerContext = controllerContext;
     return controller;
 }
        public void ConstructorSetsProperties()
        {
            // Arrange
            IFormsAuthentication formsAuth = new MockFormsAuthenticationService();
            IMembershipService membershipService = new AccountMembershipService();

            // Act
            AccountController controller = new AccountController(formsAuth, membershipService);

            // Assert
            Assert.AreEqual(formsAuth, controller.FormsAuth, "FormsAuth property did not match.");
            Assert.AreEqual(membershipService, controller.MembershipService, "MembershipService property did not match.");
        }
 private static AccountController GetAccountController()
 {
     IFormsAuthentication formsAuth = new MockFormsAuthenticationService();
     AccountController controller = new AccountController(formsAuth);
     ControllerContext controllerContext = new ControllerContext(new MockHttpContext(), new RouteData(), controller);
     controller.ControllerContext = controllerContext;
     return controller;
 }
        private static AccountController GetAccountController()
        {
            IFormsAuthentication formsAuth = new MockFormsAuthenticationService();
            MembershipProvider membershipProvider = new MockMembershipProvider();
            var membershipService = new AccountMembershipService(membershipProvider);
            var controller = new AccountController(formsAuth, new CommandServiceClient(), new MembershipReadModel());

            var controllerContext = new ControllerContext(new MockHttpContext(), new RouteData(), controller);
            controller.ControllerContext = controllerContext;
            return controller;
        }
        public void ConstructorSetsProperties()
        {
            // Arrange
            IFormsAuthentication formsAuth = new MockFormsAuthenticationService();
            var membershipReadModel = new MembershipReadModel();

            // Act  
            var controller = new AccountController(formsAuth, new CommandServiceClient(), membershipReadModel);

            // Assert
            Assert.AreEqual(formsAuth, controller.FormsAuth, "FormsAuth property did not match.");
            Assert.AreEqual(membershipReadModel, controller.MembershipReadModel,
                            "MembershipReadModel property did not match.");
        }
 private static AccountController GetAccountController()
 {
     IFormsAuthentication formsAuth = new MockFormsAuthenticationService();
     MembershipProvider membershipProvider = new MockMembershipProvider();
     AccountMembershipService membershipService = new AccountMembershipService(membershipProvider, null);
     var modRepo = new FakeModuleRepository();
     AccountController controller = new AccountController(modRepo, formsAuth, membershipService);
     ControllerContext controllerContext = new ControllerContext(new MockHttpContext(), new RouteData(), controller);
     controller.ControllerContext = controllerContext;
     return controller;
 }