public void CreateEmployer_succeeded_if_Employer_is_valid() { //arrange var Employers = new List <Employer>(); var uow = new Mock <IUnitOfWork>(); var repo = new Mock <IUserRepository>(); repo.Setup(r => r.AddEmployer(It.IsNotNull <Employer>())) .Callback <Employer>(a => Employers.Add(a)) .Verifiable(); uow.Setup(u => u.SaveChanges()) .ReturnsAsync(1) .Verifiable(); uow.Setup(u => u.UserRepository) .Returns(repo.Object) .Verifiable(); var manager = new EmployerManager(uow.Object); //act var result = manager.Create(new Employer()).Result; //assert repo.Verify(); uow.Verify(); Assert.True(result.Succeeded); Assert.Equal(1, Employers.Count); }
public void UpdateEmployer_succeeded_if_Employer_is_valid() { //arrange var uow = new Mock <IUnitOfWork>(); var repo = new Mock <IEmployerRepository>(); repo.Setup(r => r.Update(It.IsNotNull <Employer>())) .Verifiable(); uow.Setup(u => u.SaveChanges()) .ReturnsAsync(1) .Verifiable(); uow.Setup(u => u.EmployerRepository) .Returns(repo.Object) .Verifiable(); var manager = new EmployerManager(uow.Object); //act var result = manager.Update(new Employer()).Result; //assert repo.Verify(); uow.Verify(); Assert.True(result.Succeeded); }
public void Get_succeeded_if_username_is_valid() { //arrange var uow = new Mock <IUnitOfWork>(); var repo = new Mock <IUserRepository>(); var admRepo = new Mock <IEmployerRepository>(); repo.Setup(r => r.FindByUserName(It.IsNotNull <string>())) .ReturnsAsync(new User { UserId = Guid.NewGuid() }) .Verifiable(); admRepo.Setup(a => a.FindById(It.Is <Guid>(g => g != Guid.Empty))) .ReturnsAsync(new Employer()) .Verifiable(); uow.Setup(u => u.EmployerRepository) .Returns(admRepo.Object) .Verifiable(); uow.Setup(u => u.UserRepository) .Returns(repo.Object) .Verifiable(); var manager = new EmployerManager(uow.Object); //act var result = manager.Get("name").Result; //assert repo.Verify(); admRepo.Verify(); uow.Verify(); Assert.NotNull(result); }
public Int32 ReadEmployer() { Int32 Result = 0; EmployerManager EmployerManager = new EmployerManager(); Result = EmployerManager.ReadEmployer(); return(Result); }
public void DeleteEmployer_failed_if_name_is_null() { //arrange var uow = Mock.Of <IUnitOfWork>(); var manager = new EmployerManager(uow); //act var result = manager.Delete((String)null).Result; //assert Assert.False(result.Succeeded); }
public void Get_returns_null_if_username_is_not_valid() { //arrange var uow = Mock.Of <IUnitOfWork>(); var manager = new EmployerManager(uow); //act var result = manager.Get(null).Result; //assert Assert.Null(result); }
public void UpdateEmployer_failed_if_Employer_is_not_valid() { //arrange var uow = Mock.Of <IUnitOfWork>(); var manager = new EmployerManager(uow); //act var result = manager.Update(null).Result; //assert Assert.False(result.Succeeded); }
public void DeleteEmployer_failed_if_id_is_not_valid() { //arrange var uow = Mock.Of <IUnitOfWork>(); var manager = new EmployerManager(uow); //act var result = manager.Delete(Guid.Empty).Result; //assert Assert.False(result.Succeeded); }
public void DeleteEmployer_succeeded_if_name_is_valid() { //arrange var EmployerToDelete = new Employer { User = new User() }; var Employers = new List <Employer> { EmployerToDelete }; var uow = new Mock <IUnitOfWork>(); var repo = new Mock <IEmployerRepository>(); var usrRepo = new Mock <IUserRepository>(); usrRepo.Setup(u => u.Remove(It.IsNotNull <User>())) .Callback <User>(a => Employers.Remove(EmployerToDelete)) .Verifiable(); usrRepo.Setup(u => u.FindByUserName(It.IsNotNull <string>())) .ReturnsAsync(new User { UserId = Guid.NewGuid() }) .Verifiable(); repo.Setup(r => r.FindById(It.Is <Guid>(g => g != Guid.Empty))) .ReturnsAsync(EmployerToDelete) .Verifiable(); uow.Setup(u => u.SaveChanges()) .ReturnsAsync(1) .Verifiable(); uow.Setup(u => u.UserRepository) .Returns(usrRepo.Object) .Verifiable(); uow.Setup(u => u.EmployerRepository) .Returns(repo.Object) .Verifiable(); var manager = new EmployerManager(uow.Object); //act var result = manager.Delete("asdasd").Result; //assert usrRepo.Verify(); repo.Verify(); uow.Verify(); Assert.True(result.Succeeded); Assert.Equal(0, Employers.Count); }
public ActionResult Employers(EmployerSignUpView ESV) { if (ModelState.IsValid) { EmployerManager EM = new EmployerManager(); if (!EM.IsLoginNameExist(ESV.Email)) { EM.AddEmployerAccount(ESV); FormsAuthentication.SetAuthCookie(ESV.contactName, false); return(RedirectToAction("Welcome", "Home")); } else { ModelState.AddModelError("", "Login Name already taken."); } } return(View()); }
public ActionResult CreateProject(CreateProjectBindingModel model) { if (!ModelState.IsValid) { ViewBag.ModelState = ModelState; } else { var result = ProjectManager.Create(model); switch (result) { case ProjectManager.createprojectstatus.failed: ViewBag.Failed = Fa.Error; break; case ProjectManager.createprojectstatus.duplicate: ViewBag.Duplicate = Fa.DuplicateExecuter; break; default: return(RedirectToAction("Index")); } } ViewBag.Employers = EmployerManager.List(); var colleges = CollegeManager.List(); ViewBag.College = colleges; ViewBag.ResearchGroup = ResearchGroupManager.List(); if (colleges.Count > 0) { var educationalgroup = EducationalGroupManager.FindByCollegeId(colleges.FirstOrDefault().Id); ViewBag.EducationalGroup = educationalgroup; ViewBag.Executer = ExecuterManager.FindByCollegeId(colleges.FirstOrDefault().Id); } else { ViewBag.EducationalGroup = new List <EducationalGroupModel>(); ViewBag.Executer = new List <ExecuterModel>(); } ViewBag.ResearchGroup = ResearchGroupManager.List(); return(View(model)); }
public ActionResult CreateProject() { ViewBag.Employers = EmployerManager.List(); var colleges = CollegeManager.List(); ViewBag.College = colleges; ViewBag.ResearchGroup = ResearchGroupManager.List(); if (colleges.Count > 0) { var educationalgroup = EducationalGroupManager.FindByCollegeId(colleges.FirstOrDefault().Id); ViewBag.EducationalGroup = educationalgroup; ViewBag.Executer = ExecuterManager.FindByCollegeId(colleges.FirstOrDefault().Id); } else { ViewBag.EducationalGroup = new List <EducationalGroupModel>(); ViewBag.Executer = new List <ExecuterModel>(); } ViewBag.ResearchGroup = ResearchGroupManager.List(); return(View()); }
public ActionResult EditProject(int id) { var project = ProjectManager.Find(id); if (project != null) { var set = new EditProjectBindingModel { ProjectId = project.ProjectId, Title = project.Title, EmployerId = project.EmployerId, CollegeId = project.CollegeId, EducationalGroupId = project.EducationalGroupId, ExecuterId = project.ExecuterId, ResearchGroupId = project.ResearchGroupId, Price = project.Price, OverHeadPrice = project.OverHeadPrice, ReceivePrice = project.ReceivePrice, RemainPrice = project.RemainPrice, PaymentPrice = project.PaymentPrice, MainContractId = project.MainContractId, MainContractDateStr = Utility.DateToString(project.MainContractDate), InternalContractId = project.MainContractId, InternalContractDateStr = Utility.DateToString(project.InternalContractDate), ProjectEndDateStr = Utility.DateToString(project.ProjectEndDate), PhasesNum = project.PhasesNum, ProjectStatus = project.ProjectStatus, ProjectType = project.ProjectType, Explain = project.Explain, }; var colleges = CollegeManager.List(); ViewBag.College = colleges; ViewBag.EducationalGroup = EducationalGroupManager.FindByCollegeId(project.CollegeId); ViewBag.ResearchGroup = ResearchGroupManager.List(); ViewBag.Employers = EmployerManager.List(); ViewBag.Executer = ExecuterManager.FindByCollegeId(project.CollegeId); return(View(set)); } return(RedirectToAction("Index")); }
public void Get_succeeded_if_id_is_valid() { //arrange var uow = new Mock <IUnitOfWork>(); var repo = new Mock <IEmployerRepository>(); repo.Setup(r => r.FindById(It.Is <Guid>(g => g != Guid.Empty))) .ReturnsAsync(new Employer()) .Verifiable(); uow.Setup(u => u.EmployerRepository) .Returns(repo.Object) .Verifiable(); var manager = new EmployerManager(uow.Object); //act var result = manager.Get(Guid.NewGuid()).Result; //assert repo.Verify(); uow.Verify(); Assert.NotNull(result); }
public ActionResult ProjectInfo(int id) { var project = ProjectManager.Find(id); if (project != null) { var set = new ProjectViewModel { Title = project.Title, ProjectId = project.ProjectId, Price = project.Price, OverHeadPrice = project.OverHeadPrice, ReceivePrice = project.ReceivePrice, RemainPrice = project.RemainPrice, PaymentPrice = project.PaymentPrice, MainContractId = project.MainContractId, MainContractDate = Utility.DateToString(project.MainContractDate), InternalContractId = project.MainContractId, InternalContractDate = Utility.DateToString(project.InternalContractDate), ProjectEndDate = Utility.DateToString(project.ProjectEndDate), PhasesNum = project.PhasesNum, ProjectStatus = project.ProjectStatus, ProjectType = project.ProjectType, Explain = project.Explain, Id = project.Id, }; set.Employer = EmployerManager.Find(project.EmployerId).Name; var executer = ExecuterManager.FindExecuter(project.ExecuterId); set.Executer = executer.FirstName + " " + executer.LastName; set.College = CollegeManager.Find(project.CollegeId).Name; set.EducationalGroup = EducationalGroupManager.Find(project.EducationalGroupId).Name; set.ResearchGroup = ResearchGroupManager.Find(project.ResearchGroupId).Name; ViewBag.ProjectInfo = set; return(View()); } return(RedirectToAction("Error")); }
public Boolean insertEmployer(EmployerDto dto) { Employer obj = Employer.createEmployer(dto.EmployerId, dto.EmployerName); EmployerManager mgr = new EmployerManager(); return mgr.insertEmployer(obj); }
public List<EmployerDto> selectAllEmployer() { EmployerManager mgr = new EmployerManager(); List<Employer> employerList = mgr.selectAllEmployer(); List<EmployerDto> dtoList = new List<EmployerDto>(); foreach (Employer employer in employerList) { dtoList.Add(EmployerDto.createEmployerDTO(employer)); } return dtoList; }
public EmployerDto selectEmployerById(System.Guid EmployerId) { EmployerManager mgr = new EmployerManager(); Employer obj = new Employer(); obj.EmployerId = EmployerId; obj = mgr.selectEmployerById(obj); if (obj != null) { return EmployerDto.createEmployerDTO(obj); } else { return null; } }
public EmployerController(DataBaseContext dbContext) { this._dbContext = dbContext; _employerManager = new EmployerManager(dbContext); }
public Boolean insertEmployer(System.Guid EmployerId, String EmployerName) { Employer obj = Employer.createEmployer(EmployerId, EmployerName); EmployerManager mgr = new EmployerManager(); return mgr.insertEmployer(obj); }