public void TestCreateNewUser_NameToShort() { User user = new User { UserID = 7, UserName = "******", Password = "******", Email = "TestEmail", Permission = Permission.RegisteredUser, FilmReviews = null }; UsersController userController = new UsersController(); // Act ViewResult result = userController.Create(user.UserName, user.Password, user.Email, user) as ViewResult; // Assert Assert.AreEqual("Invalid Input Length", result.ViewBag.Message); }
public void TestCreateNewUser_DuplicateName() { User user = new User { UserID = 5, UserName = "******", Password = "******", Email = "TestEmail", Permission = Permission.RegisteredUser, FilmReviews = null }; UsersController userController = new UsersController(); // Act ViewResult result = userController.Create(user.UserName, user.Password, user.Email, user) as ViewResult; // Assert Assert.AreEqual("Duplicate Name", result.ViewBag.Message); }
public void TestLogin_ValidInput() { //var result = (RedirectToRouteResult)controller.Register(registrModel); /*result.RouteValues["action"].Equals("Index"); result.RouteValues["controller"].Equals("Home"); Assert.AreEqual("Index", action.RouteValues["action"]); Assert.AreEqual("Home", action.RouteValues["controller"]);*/ UsersController userController = new UsersController(); HomeController homeController = new HomeController(); // Act ViewResult result = userController.Login("gary", "nicolson") as ViewResult; ViewResult result2 = homeController.Index() as ViewResult; // Assert Assert.AreEqual("Valid", result2.ViewBag.message); }
public void TestLogin_Null_Entry() { UsersController userController = new UsersController(); // Act ViewResult result = userController.Login(null, null) as ViewResult; // Assert Assert.AreEqual("Invalid UserName", result.ViewBag.message); }
public void TestLogin_InvalidPassword() { UsersController userController = new UsersController(); // Act ViewResult result = userController.Login("gary", "nicol") as ViewResult; // Assert Assert.AreEqual("Invalid Password", result.ViewBag.message); }
public void TestLogin_IncorrectUserName() { UsersController userController = new UsersController(); // Act ViewResult result = userController.Login("gazaz", "nicolson") as ViewResult; // Assert Assert.AreEqual("Invalid UserName", result.ViewBag.message); }