Beispiel #1
0
        public void HomeController_CompletedLoginNoUsername()
        {
            _memeberShipService.Setup(s => s.IsUserRegistered(It.IsAny <string>())).Returns(false);

            HomeController     homeController  = new HomeController(_memeberShipService.Object);
            CompleteLoginModel beginLoginModel = new CompleteLoginModel {
                UserName = string.Empty
            };

            ViewResult result = homeController.CompletedLogin(beginLoginModel) as ViewResult;

            Assert.IsNotNull(result);
            Assert.IsFalse(homeController.ModelState.IsValid);
            Assert.AreEqual("FinishLogin", result.ViewName);
        }
Beispiel #2
0
        public void HomeController_CompletedLoginExceptionThrown()
        {
            _memeberShipService.Setup(s => s.AuthenticateUser(It.IsAny <string>(), It.IsAny <string>())).Throws(new Exception());
            _memeberShipService.Setup(s => s.IsUserRegistered(It.IsAny <string>())).Returns(true);

            HomeController     homeController  = new HomeController(_memeberShipService.Object);
            CompleteLoginModel beginLoginModel = new CompleteLoginModel {
                UserName = "******"
            };

            ViewResult result = homeController.CompletedLogin(beginLoginModel) as ViewResult;

            Assert.IsNotNull(result);
            Assert.IsFalse(homeController.ModelState.IsValid);
            Assert.AreEqual("FinishLogin", result.ViewName);
        }
Beispiel #3
0
        public void HomeController_CompletedLoginWithUsername()
        {
            _memeberShipService.Setup(s => s.IsUserRegistered(It.Is <string>(p => p == "tester"))).Returns(true);
            _memeberShipService.Setup(s => s.AuthenticateUser(It.Is <string>(p => p == "tester"), It.Is <string>(p => p == "notrealdeviceresponse"))).Returns(true);

            HomeController     homeController  = new HomeController(_memeberShipService.Object);
            CompleteLoginModel beginLoginModel = new CompleteLoginModel
            {
                UserName       = "******",
                DeviceResponse = "notrealdeviceresponse"
            };

            var result = homeController.CompletedLogin(beginLoginModel) as RedirectToRouteResult;

            Assert.IsNotNull(result);
            Assert.AreEqual("Index", result.RouteValues["action"] as string);
        }
Beispiel #4
0
        public void HomeController_CompletedLoginWithUsername()
        {
            _memeberShipService.Setup(s => s.IsUserRegistered(It.Is <string>(p => p == "tester"))).Returns(true);
            _memeberShipService.Setup(s => s.AuthenticateUser(It.Is <string>(p => p == "tester"), It.Is <string>(p => p == "notrealdeviceresponse"))).Returns(true);

            HomeController     homeController  = new HomeController(_memeberShipService.Object);
            CompleteLoginModel beginLoginModel = new CompleteLoginModel
            {
                UserName       = "******",
                DeviceResponse = "notrealdeviceresponse"
            };

            ViewResult result = homeController.CompletedLogin(beginLoginModel) as ViewResult;

            Assert.IsNotNull(result);
            Assert.IsTrue(homeController.ModelState.IsValid);
            Assert.AreEqual("CompletedLogin", result.ViewName);
        }