public void WhenUserNameIsNulOrEmptyValidateUserTest(
            [Values("", null)] string userName,
            [Values("pass", "Test Password", "", null)] string password)
        {
            _dbContextMock.Setup(mockContext => mockContext.User).Returns(_dbSetMock.Object);

            // setup of Mock User Repository
            var target = _dbContextMock.Object;
            bool isValid;
            _userRepository = new UserRepository(target);
            bool success = _userRepository.ValidateUser(userName, password, out isValid);

            // assert
            _dbContextMock.VerifyAll();
            Assert.That(false, Is.EqualTo(success));
        }
        public void WhenMethodChangePasswordIsCalledByNullOrEmptyOrInvalidUsernameReturnFalse(
            [Values("John Pirce", "Edward Bolton", "", null)]string userName,
            [Values("Johns Password", "Boltons Password", null)]string password)
        {
            // return a user by Name
            _dbContextMock.Setup(mockContext => mockContext.User).Returns(_dbSetMock.Object);

            // setup of Mock User Repository
            var target = _dbContextMock.Object;
            User testUser;
            _userRepository = new UserRepository(target);
            var success = _userRepository.ChangePassword(userName, password);

            // assert
            _dbContextMock.VerifyAll();
            Assert.That(false, Is.EqualTo(success));
        }
        public void WhenMethodGetUserByNameTestIsCalledByUsernameReturnUser(string userName)
        {
            // return a user by Name
            _dbContextMock.Setup(mockContext => mockContext.User).Returns(_dbSetMock.Object);

            // setup of Mock User Repository
            var target = _dbContextMock.Object;
            User testUser;
            _userRepository = new UserRepository(target);
            var success = _userRepository.GetUserBy(userName, out testUser);

            // assert
            _dbContextMock.VerifyAll();
            Assert.That(true, Is.EqualTo(success));
            if (userName == testUser.Name)
            {
                Assert.That(userName, Is.EqualTo(testUser.Name));
            }
            else
            {
                Assert.That(userName, Is.Not.EqualTo(testUser.Name));
            }
        }
        public void WhenUserNameAndPasswordIsProvidedValidateUserTest(
            [Values("Richard Child", "Chris Smith", "Awin George")] string userName,
            [Values("pass", "Test Password")] string password)
        {
            _dbContextMock.Setup(mockContext => mockContext.User).Returns(_dbSetMock.Object);

            // setup of Mock User Repository
            var target = _dbContextMock.Object;
            bool isValid;
            _userRepository = new UserRepository(target);
            bool success = _userRepository.ValidateUser(userName, password, out isValid);

            // assert
            _dbContextMock.VerifyAll();
            if (success)
            {
                Assert.That(true, Is.EqualTo(success));

                if (isValid) Assert.IsTrue(isValid);
                else Assert.IsFalse(isValid);
            }
            else Assert.That(false, Is.EqualTo(success));
        }
        public void WhenMethodGetUserByIsCalledByNullOrEmptyUsernameReturnFalse(string userName)
        {
            // return a user by Name
            _dbContextMock.Setup(mockContext => mockContext.User).Returns(_dbSetMock.Object);

            // setup of Mock User Repository
            var target = _dbContextMock.Object;
            User testUser;
            _userRepository = new UserRepository(target);
            var success = _userRepository.GetUserBy(userName, out testUser);

            // assert
            _dbContextMock.VerifyAll();
            Assert.That(false, Is.EqualTo(success));
        }
        public void WhenMethodGetUserByIdTestIsCalledReturnUser()
        {
            // Return a user by Id
            _dbContextMock.Setup(mockContext => mockContext.User).Returns(_dbSetMock.Object);

            // setup of our Mock User Repository
            var target = _dbContextMock.Object;
            User testUser;
            _userRepository = new UserRepository(target);
            var success = _userRepository.GetUserBy(2, out testUser);

            // assert
            _dbContextMock.VerifyAll();
            Assert.That(true, Is.EqualTo(success));
            Assert.That("Chris Smith", Is.EqualTo(testUser.Name));
            Assert.That("Richard Child", Is.Not.EqualTo(testUser.Name));
            Assert.That(2, Is.EqualTo(testUser.id));
        }
        public void WhenMethodGetAllUersIsCalledReturnUsers()
        {
            // Return all users
            _dbContextMock.Setup(x => x.User).Returns(_dbSetMock.Object);

            // setup of our Mock User Repository
            dbContext target = _dbContextMock.Object;
            IList<User> testUser;
            _userRepository = new UserRepository(target);
            var success = _userRepository.GetAllUsers(out testUser);

            // assert
            _dbContextMock.VerifyAll();
            Assert.That(true, Is.EqualTo(success));
            Assert.That(3, Is.EqualTo(testUser.Count));
            Assert.That(null, Is.Not.EqualTo(testUser));
            Assert.That(
                false,
                Is.EqualTo(testUser.Where(p => p.Name == "Awin George").Select(p => p.IsDeleted).First()));
        }
        public void WhenMethodGetAllActiveUsersIsCalledReturnUsers()
        {
            // return a user by Name
            _dbContextMock.Setup(x => x.User).Returns(_dbSetMock.Object);

            // setup of Mock User Repository
            var target = _dbContextMock.Object;

            IUserRepository userRepository = new UserRepository(target);
            IList<User> testUserList;
            var success = userRepository.GetAllUsersBy(true, out testUserList);

            // assert
            _dbContextMock.VerifyAll();
            Assert.That(true, Is.EqualTo(success));
            Assert.That(2, Is.EqualTo(testUserList.Count));
        }
        public void WhenMethodChangePasswordIsCalledByValidUsernameAndValidPasswordIsProvidedReturnTrue(string userName, string password)
        {
            // return a user by Name
            _dbContextMock.Setup(mockContext => mockContext.User).Returns(_dbSetMock.Object);

            // setup of Mock User Repository
            var target = _dbContextMock.Object;
            User testUser;
            _userRepository = new UserRepository(target);
            var success = _userRepository.ChangePassword(userName, password);

            // assert
            _dbContextMock.VerifyAll();
            Assert.That(true, Is.EqualTo(success));
        }