示例#1
0
        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);
        }
示例#2
0
        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);
            }
        }
示例#3
0
        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);
        }