Example #1
0
        public void Login_InvalidPassword()
        {
            var now = DateTime.Now;

            var user = new User()
            {
                UserId = 0,
                UserName = "******",
                Password = "******",
                LastLoginDate = now,
                LoginAttempts = 3,
                Locked = false,
                Active = true,
                CreatedOn = now,
                CreatedBy = "CreatedBy",
                ModifiedOn = now,
                ModifiedBy = "ModifiedBy"
            };

            _contextMock.Setup(m => m.User).Returns(new FakeDbSet<User> { user });

            var result = _userService.Login(user.UserName, "wrongpassword");

            Assert.AreEqual(LoginStatus.InvalidPassword, result.Status);
        }
Example #2
0
        public void Login_Success()
        {
            var now = DateTime.Now;

            var user = new User()
            {
                UserId = 0,
                UserName = "******",
                Password = "******",
                LastLoginDate = now,
                LoginAttempts = 3,
                Locked = false,
                Active = true,
                CreatedOn = now,
                CreatedBy = "CreatedBy",
                ModifiedOn = now,
                ModifiedBy = "ModifiedBy"
            };

            _contextMock.Setup(m => m.User).Returns(new FakeDbSet<User> { user });

            //_userBusinessMock.Setup(m => m.SetSuccessfullLogin)
            var result = _userService.Login(user.UserName, user.Password);

            Assert.AreEqual(LoginStatus.Success, result.Status);
            Assert.AreEqual(_configMock.Object.LoginAttemptsAllowed, result.AttemptsRemaining);
        }
Example #3
0
        public void SaveNewUser(string username, string password)
        {
            var now = DateTime.Now;

            var user = new User
            {
                UserName = username,
                Password = password,
                LoginAttempts = 0,
                Active = true,
                Locked = false,
                LastLoginDate = now,
                CreatedBy = username,
                CreatedOn = now,
                ModifiedBy = username,
                ModifiedOn = now
            };

            _context.User.Add(user);
            _context.SaveChanges();
        }