public void IsUsernameOrPasswordEmpty_EmpytyUsernameOrPassword_ReturnsFalse(string username, string password) { StubSuccessUserContext stubSuccessUserContext = new StubSuccessUserContext(); AuthenticationService authenticationService = new AuthenticationService(stubSuccessUserContext); bool isValid = authenticationService.IsUsernameOrPasswordEmpty(username, password); Assert.True(isValid); }
public void Login_NotExistUser_ThrowArgumentException(string username, string hashPassword) { StubSuccessUserContext stubSuccessUserContext = new StubSuccessUserContext(); AuthenticationService authenticationService = new AuthenticationService(stubSuccessUserContext); try { User actualUser = authenticationService.Login(username, hashPassword); Assert.True(false, "ArgumentException was not thrown"); } catch (ArgumentException) { // Assert Assert.True(true); } }
public void Login_CorrectUser_ReturnsExpectedUser() { var username = "******"; var hashPassword = "******"; var expectedUser = new User() { Id = 1, Username = "******", Displayname = "พลอย" }; StubSuccessUserContext stubSuccessUserContext = new StubSuccessUserContext(); AuthenticationService authenticationService = new AuthenticationService(stubSuccessUserContext); User actualUser = authenticationService.Login(username, hashPassword); // Assert Assert.IsType <User>(actualUser); Assert.Equal(expectedUser.Id, actualUser.Id); Assert.Equal(expectedUser.Username, actualUser.Username); Assert.Equal(expectedUser.Displayname, actualUser.Displayname); }