public void TestLogoutWithWrongUserRoleShouldReturnAppropriateMessage() { IBangaloreUniversityData data = new BangaloreUniversityData(); User user = new User("firstLecturer", "firstPass", Role.Guest); UsersController controller = new UsersController(data, user); controller.Logout().Display(); }
public void TestLogoutIfNoUserIsLoggedInShouldReturnAppropriateMessage() { IBangaloreUniversityData data = new BangaloreUniversityData(); User user = new User("firstLecturer", "firstPass", Role.Lecturer); UsersController controller = new UsersController(data, null); controller.Logout().Display(); }
public void TestLogoutWhileNotLoggedIn_ShouldThrowArgumentException() { // Arrange IBangaloreUniversityDatabase database = new BangaloreUniversityDatabase(); UsersController controller = new UsersController(database, null); // Act controller.Logout(); }
public void TestSuccessfullLogoutShouldReturnAppropriateMessage() { IBangaloreUniversityData data = new BangaloreUniversityData(); User user = new User("firstLecturer", "firstPass", Role.Lecturer); UsersController controller = new UsersController(data, user); string message = controller.Logout().Display(); Assert.AreEqual("User firstLecturer logged out successfully.", message); }
public void TestLogoutWhileLoggedInWithIncorectRole_ShouldThrowAuthorizationFailedException() { // Arrange IBangaloreUniversityDatabase database = new BangaloreUniversityDatabase(); User user = new User("test user", "password", Role.ForTestingPurposesOnly); UsersController controller = new UsersController(database, user); // Act controller.Logout(); }
public void Logout_WithValidInput_ShouldReturnAIViewObject() { var user = new Mock<User>("Ivan Ivanov", "123456", Role.Student); var database = new Mock<IBangaloreUniversityDatabase>(); var userController = new UsersController(database.Object, user.Object); Assert.AreEqual(user.Object, userController.CurrentUser); var result = userController.Logout(); NUnit.Framework.Assert.IsInstanceOf(typeof(IView), result); }
public void Logout_WithValidInput_ShouldLogOutUser() { var user = new Mock<User>("Ivan Ivanov", "123456", Role.Student); var database = new Mock<IBangaloreUniversityDatabase>(); var userController = new UsersController(database.Object, user.Object); Assert.AreEqual(user.Object, userController.CurrentUser); userController.Logout(); Assert.AreEqual(null, userController.CurrentUser); }
public void TestLogout_InitializeNullUser_ShouldThrow() { // Arrange User user = null; var database = new BangaloreUniversityData(); var controller = new UsersController(database, user); // Act controller.Logout(); // Assert }
public void TestLogout_InitializeGuestUser_ShouldThrow() { // Arrange User user = new User("gosho", "123456", Role.Guest); var database = new BangaloreUniversityData(); var controller = new UsersController(database, user); // Act controller.Logout(); // Assert }
public void TestLogout_LogoutValidUser_CurrentUserShouldBeNull() { // Arrange User user = new User("gosho", "123456", Role.Lecturer); var database = new BangaloreUniversityData(); var controller = new UsersController(database, user); // Act controller.Logout(); // Assert Assert.IsNull(controller.User, "User should be null."); }
public void Logout_WithNoLoggedInUser_ShouldThrowACorrectException() { var exception = NUnit.Framework.Assert.Catch<ArgumentException>( () => { var database = new Mock<IBangaloreUniversityDatabase>(); var userController = new UsersController(database.Object, null); userController.Logout(); }); Assert.AreEqual(Constants.NoLoggedInUserMessage, exception.Message); }
public void TestLogoutWhileLoggedIn_ShouldReturnCorrectResult() { // Arrange IBangaloreUniversityDatabase database = new BangaloreUniversityDatabase(); User user = new User("test user", "password", Role.Student); UsersController controller = new UsersController(database, user); // Act IView view = controller.Logout(); string reuslt = view.Display(); // Assert Assert.AreEqual("User test user logged out successfully.", reuslt); }