public void authenticateUserTest()
 {
     iUserServices.Setup(m => m.athenticateUserWithHash(It.IsAny<string>()));
     UserController target = new UserController(iCommentServices.Object, iUserServices.Object);
     Random random  = new Random();
     string hash = random.Next().ToString();
     var actual = target.authenticateUser(hash) as RedirectToRouteResult;
     Assert.IsNotNull(actual);
     Assert.AreEqual(actual.RouteValues["action"], "indexAfterRegister");
     Assert.AreEqual(actual.RouteValues["controller"], "Home");
 }
 public void connectNoExistingUserTest()
 {
     Users users = null;
     iUserServices.Setup(m => m.findUserByUserName(It.IsAny<string>())).Returns(users);
     UserController target = new UserController(iCommentServices.Object,iUserServices.Object);
     Users user = new Users();
     var actual = target.connect(user) as RedirectToRouteResult;
     Assert.IsNotNull(actual);
     Assert.AreEqual(actual.RouteValues["action"], "indexWithoutVoice");
     Assert.AreEqual(actual.RouteValues["controller"], "Home");
 }
 public void connectExistingUserAndDiferentePasswordTest()
 {
     CryptographyController cryptoController = new CryptographyController();
     Users user1 = new Users();
     Users user2 = new Users();
     user1.password = cryptoController.getMD5Hash("teste");
     iUserServices.Setup(m => m.findUserByUserName(It.IsAny<string>())).Returns(user1);
     UserController target = new UserController(iCommentServices.Object, iUserServices.Object);
     UserController target2 = new UserController(iCommentServices.Object, iUserServices.Object);
     user2.password = "******";
     var actual = target.connect(user2) as RedirectToRouteResult;
     Assert.IsNotNull(actual);
     Assert.AreEqual(actual.RouteValues["action"], "indexWithoutVoice");
     Assert.AreEqual(actual.RouteValues["controller"], "Home");
 }
 public void registerOkTest()
 {
     iUserServices.Setup(m => m.hasAUserWithThisEmail(It.IsAny<string>())).Returns(false);
     iUserServices.Setup(m => m.addUser(It.IsAny<Users>()));
     UserController target = new UserController(iCommentServices.Object, iUserServices.Object);
     Users user = new Users();
     Random random = new Random();
     user.password = random.Next().ToString();
     RedirectToRouteResult actual = target.register(user, user.password) as RedirectToRouteResult;
     Assert.IsNotNull(actual);
     Assert.AreEqual(actual.RouteValues["action"], "index");
     Assert.AreEqual(actual.RouteValues["controller"], "Home");
 }
 public void registerDiferrentPasswordTest()
 {
     UserController target = new UserController(iCommentServices.Object, iUserServices.Object);
     Users user = new Users();
     string confirmPassword = "******";
     user.password = "******";
     ViewResult actual = target.register(user,confirmPassword) as ViewResult;
     TempDataDictionary tempData = actual.TempData as TempDataDictionary;
     ModelStateDictionary modelState = tempData["ModelState"] as ModelStateDictionary;
     Assert.IsNotNull(actual);
     Assert.IsTrue(modelState.ContainsKey("password"));
     Assert.IsTrue(modelState.ContainsKey("confirmPassword"));
 }
 public void registerAlreadyExistUserTest()
 {
     iUserServices.Setup(m => m.hasAUserWithThisEmail(It.IsAny<string>())).Returns(true);
     UserController target = new UserController(iCommentServices.Object, iUserServices.Object);
     Users user = new Users();
     Random random = new Random();
     user.password =  random.Next().ToString();
     ViewResult actual = target.register(user, user.password) as ViewResult;
     TempDataDictionary tempData = actual.TempData as TempDataDictionary;
     ModelStateDictionary modelState = tempData["ModelState"] as ModelStateDictionary;
     Assert.IsNotNull(actual);
     Assert.IsTrue(modelState.ContainsKey("userName"));
 }
 public void register1Test()
 {
     UserController target = new UserController(iCommentServices.Object, iUserServices.Object);
     var actual = target.register() as ViewResult;
     Assert.IsNotNull(actual);
 }
 public void logOutTest()
 {
     UserController target = new UserController(iCommentServices.Object, iUserServices.Object);
     var actual = target.logOut() as RedirectToRouteResult;
     Assert.IsNotNull(actual);
     Assert.AreEqual(actual.RouteValues["action"], "index");
     Assert.AreEqual(actual.RouteValues["controller"], "Home");
 }
 public void IndexTest()
 {
     iCommentServices.Setup(m => m.findCommentsByIdUser(It.IsAny<int>())).Returns(new List<Comments>());
     UserController target = new UserController(iCommentServices.Object,iUserServices.Object);
     ViewResult actual = target.Index() as ViewResult;
     ViewDataDictionary viewData = actual.ViewData;
     Assert.IsNotNull(actual);
     Assert.IsNotNull(viewData["commentsFromUser"]);
 }