public void LogOut_Success() { // Setup var formsAuthentication = new Mock<IFormsAuthenticationService>(); var userService = new Mock<IUserService>(); IMembershipManagementService membershipManagementService = new MembershipManagementService(userService.Object, formsAuthentication.Object, new Mock<IEUniversityUow>().Object, new Mock<IAuthorizationService>().Object, new Mock<IRoleService>().Object, new Mock<IStudentProfileService>().Object); // Action membershipManagementService.LogOut(); // Verify the result formsAuthentication.Verify(x => x.LogOut(), Times.Once()); }
public void ValidUserTryLogIn_UserLogIn() { // Setup var user = new LoginViewModel() { Email = "Matthew", Password = "******" }; var formsAuthentication = new Mock<IFormsAuthenticationService>(); var userService = new Mock<IUserService>(); userService.Setup(f => f.ValidateUser(user.Email, user.Password)).Returns(true); IMembershipManagementService membershipManagementService = new MembershipManagementService(userService.Object, formsAuthentication.Object, new Mock<IEUniversityUow>().Object, new Mock<IAuthorizationService>().Object, new Mock<IRoleService>().Object, new Mock<IStudentProfileService>().Object); // Action var isLogIn = membershipManagementService.LogIn(user); // Verify the result formsAuthentication.Verify(x => x.SetAuthCookie(It.IsAny<string>(), false), Times.Once()); Assert.IsTrue(isLogIn); }