Пример #1
0
        public void When_LoginUserWithCorrectPassword_Then_ReturnUser()
        {
            //Arrange
            var userEmail     = "*****@*****.**";
            var password      = "******";
            var passwordHased = password + "hased";
            var mockedUsers   = new List <User> {
                new User()
                {
                    Id = Guid.NewGuid(), UserEmail = "*****@*****.**", PasswordHash = ""
                },
                new User()
                {
                    Id = Guid.NewGuid(), UserEmail = userEmail, PasswordHash = passwordHased
                },
                new User()
                {
                    Id = Guid.NewGuid(), UserEmail = "*****@*****.**", PasswordHash = ""
                }
            };

            _hasher.Setup(e => e.CalculateHash(password)).Returns(passwordHased);
            _repository.Setup(e => e.List()).Returns(mockedUsers);

            IAuthenticationDomain sut = new AuthenticationDomain(_repository.Object, _hasher.Object);

            //Action
            var user = sut.LogInUser(userEmail, password);

            //Assert
            Assert.IsNotNull(user);
        }
Пример #2
0
        public void When_EmailIsEmpty_Then_ReturnNull()
        {
            //Arrange
            var userEmail = "";
            var password  = "******";

            IAuthenticationDomain sut = new AuthenticationDomain(_repository.Object, _hasher.Object);

            //Action
            var user = sut.LogInUser(userEmail, password);

            //Assert
            Assert.IsNull(user);
        }
Пример #3
0
        public void When_LoginUserDoesntExist_Then_ReturnNull()
        {
            //Arrange
            var userEmail     = "*****@*****.**";
            var password      = "******";
            var passwordHased = password + "hased";
            var mockedUsers   = new List <User>();

            _hasher.Setup(e => e.CalculateHash(password)).Returns(passwordHased + "old");
            _repository.Setup(e => e.List()).Returns(mockedUsers);

            IAuthenticationDomain sut = new AuthenticationDomain(_repository.Object, _hasher.Object);

            //Action
            var user = sut.LogInUser(userEmail, password);

            //Assert
            Assert.IsNull(user);
        }