public object CheckUser(string login, string password) { password = DecryptPassword(password); if (uow.UsersRepository.Get().FirstOrDefault(c => c.Login == login && c.Password == password) != null) { return(CustomMapper.getUserBLL(uow.UsersRepository.Get().FirstOrDefault(c => c.Login == login && c.Password == password))); } if (uow.RecruitersRepository.Get().FirstOrDefault(c => c.Login == login && c.Password == password) != null) { return(CustomMapper.getRecruiterBLL(uow.RecruitersRepository.Get().FirstOrDefault(c => c.Login == login && c.Password == password))); } if (uow.AdminsRepository.Get().FirstOrDefault(c => c.Login == login && c.Password == password) != null) { return(CustomMapper.getAdminBLL(uow.AdminsRepository.Get().FirstOrDefault(c => c.Login == login && c.Password == password))); } else { return(null); } }
public void TestCheckUser() { User user1 = new User() { Login = "******", Password = "******" }; User user2 = new User() { Login = "******", Password = "******" }; List <User> users = new List <User>() { user1, user2 }; Recrutier recrutier1 = new Recrutier() { Login = "******", Password = "******" }; Recrutier recrutier2 = new Recrutier() { Login = "******", Password = "******" }; List <Recrutier> recrutiers = new List <Recrutier>() { recrutier1, recrutier2 }; Admin admin1 = new Admin() { Login = "******", Password = "******" }; Admin admin2 = new Admin() { Login = "******", Password = "******" }; List <Admin> admins = new List <Admin>() { admin1, admin2 }; mockUnitOfWork = kernel.Get <IUnitOfWork>(); IGenericRepository <User> mockUserRepository = kernel.Get <IGenericRepository <User> >(); mockUserRepository.Get().Returns(users); mockUnitOfWork.UsersRepository.Returns(mockUserRepository); IGenericRepository <Recrutier> mockRecrutierRepository = kernel.Get <IGenericRepository <Recrutier> >(); mockRecrutierRepository.Get().Returns(recrutiers); mockUnitOfWork.RecruitersRepository.Returns(mockRecrutierRepository); IGenericRepository <Admin> mockAdminRepository = kernel.Get <IGenericRepository <Admin> >(); mockAdminRepository.Get().Returns(admins); mockUnitOfWork.AdminsRepository.Returns(mockAdminRepository); verificationSubSys = new VerificationSubSystem(mockUnitOfWork); AdminBLL expected = CustomMapper.getAdminBLL(admin1); AdminBLL real = (AdminBLL)verificationSubSys.CheckUser("admin1", ":"); Assert.AreEqual(expected.Login, real.Login); }