public void ValidateUserNotFoundTest()
        {
            const string Name = "user";
            const string Password = "******";
            string message;

            AccountService accountService = new AccountService(_dalContext);
            _dalContext.Expect(x => x.UsersRepository).Return(_usersRepository).Repeat.Once();
            _usersRepository.Expect(x => x.GetUserByNameAndPassword(Name, Password)).Return(null);
            _mockRepository.ReplayAll();

            User actual = accountService.ValidateUser(Name, Password, out message);

            Assert.AreEqual(null, actual);
            Assert.AreEqual(AccountService.UserNotFoundMessage, message);
            _mockRepository.VerifyAll();
        }
        public void ValidateUserSuccessTest()
        {
            const string Name = "user";
            const string Password = "******";
            User user = new User();
            List<Role> roles = new List<Role>
                {
                    new Role
                        {
                            Key = 1,
                            Name = "Vassas",
                            Description = "Blah"
                        }
                };
            string message;

            AccountService accountService = new AccountService(_dalContext);
            _dalContext.Expect(x => x.UsersRepository).Return(_usersRepository).Repeat.Once();
            _dalContext.Expect(x => x.RolesRepository).Return(_rolesRepository).Repeat.Once();
            _usersRepository.Expect(x => x.GetUserByNameAndPassword(Name, Password)).Return(user);
            _rolesRepository.Expect(x => x.GetRolesForUser(Name)).Return(roles).Repeat.Once();

            _mockRepository.ReplayAll();
            User actual = accountService.ValidateUser(Name, Password, out message);

            Assert.AreEqual(user, actual);
            CollectionAssert.AreEqual(roles, user.Roles.ToList());
            Assert.IsNull(message);
            _mockRepository.VerifyAll();
        }
        public void ValidateUserDALErrorTest()
        {
            const string Name = "user";
            const string Password = "******";
            string message;

            AccountService accountService = new AccountService(_dalContext);
            _dalContext.Expect(x => x.UsersRepository).Return(_usersRepository).Repeat.Once();
            _usersRepository.Expect(x => x.GetUserByNameAndPassword(Name, Password)).Throw(new DbException("An error"));
            _mockRepository.ReplayAll();

            User actual = accountService.ValidateUser(Name, Password, out message);

            Assert.AreEqual(null, actual);
            Assert.AreEqual(AccountService.ErrorDuringReadingUserMessage, message);
            _mockRepository.VerifyAll();
        }