Esempio n. 1
0
        public void LockUser()
        {
            var lockAccountStrategy = new Mock <ILockAccountStrategy>();

            var authenticateCandidateStrategy =
                new AuthenticateCandidateStrategyBuilder().WithUserAuthenticatingCorrectly(false)
                .With(lockAccountStrategy).Build();

            // Act
            authenticateCandidateStrategy.AuthenticateCandidate("username", "password");

            //Assert
            lockAccountStrategy.Verify(l => l.LockAccount(It.IsAny <User>()));
        }
        public void DormantUserSetToActiveAfterSuccessfulLogin()
        {
            var user = new UserBuilder(Guid.NewGuid()).WithStatus(UserStatuses.Dormant).Build();

            var userReadRepository = new Mock <IUserReadRepository>();

            userReadRepository.Setup(r => r.Get(It.IsAny <string>(), It.IsAny <bool>())).Returns(user);
            var userWriteRepository = new Mock <IUserWriteRepository>();
            var strategy            = new AuthenticateCandidateStrategyBuilder().With(userReadRepository).With(userWriteRepository).Build();

            strategy.AuthenticateCandidate("username", "password");

            userWriteRepository.Verify(uwr => uwr.Save(It.Is <User>(u => u.Status == UserStatuses.Active)));
        }
Esempio n. 3
0
        public void UnlockUser()
        {
            // Arrange
            var userWriteRepository = new Mock <IUserWriteRepository>();

            var authenticateCandidateStrategy =
                new AuthenticateCandidateStrategyBuilder().WithUserAuthenticatingCorrectly(true)
                .With(userWriteRepository).Build();

            // Act
            authenticateCandidateStrategy.AuthenticateCandidate("username", "password");

            //Assert
            userWriteRepository.Verify(uwr => uwr.Save(It.Is <User>(u => u.LoginIncorrectAttempts == 0)));
        }