public async Task CreateJobOffer_SaveSuccessfully_WhenJobOfferDataIsCorrect() { //Arrange var recruiter = new Recruiter() { FirstName = "Maidana", LastName = "Patricia", IdentityCard = "28123456" }; await _recruiterRepository.UpsertAsync(recruiter); var company = new Company("Acme", "Software"); recruiter.AddClientCompany(company); var skill1 = new Skill() { Name = "C#" }; var skill2 = new Skill() { Name = "Javascript" }; var skill3 = new Skill() { Name = "React" }; await _skillRepository.UpsertAsync(skill1); await _skillRepository.UpsertAsync(skill2); await _skillRepository.UpsertAsync(skill3); var jobOffer = new JobOffer() { Title = "Analista Funcional", Description = "Se necesita analista funcional con bla bla bla", Owner = recruiter, Date = DateTime.Now.Date }; jobOffer.AddSkillRequired(new SkillRequired(skill1, 5, true)); jobOffer.AddSkillRequired(new SkillRequired(skill2, 4, false)); jobOffer.AddSkillRequired(new SkillRequired(skill3, 2, false)); //Act await _service.CreateJobOffer(jobOffer, recruiter); var jobOfferCreated = await _jobOfferRepository.GetByIdAsync(jobOffer.Id); //Assert Assert.AreEqual(jobOffer, jobOfferCreated, "Job offer was not saved"); }
public virtual async Task ApplyToJobOfferAsync(string jobOfferId, string accountId) { var account = await _accountRepository.GetByIdAsync(accountId); if (account != null) { var jobOffer = await _jobOffersRepository.GetByIdAsync(jobOfferId); if (jobOffer != null) { var person = await _personRepository.GetByIdAsync(account.PersonId); if (person != null) { person.ApplyToJobOffer(jobOffer); //This should be transactional await _jobOffersRepository.UpsertAsync(jobOffer); await _personRepository.UpsertAsync(person); } else { throw new InvalidOperationException(ServicesErrorMessages.PERSON_DOES_NOT_EXISTS); } } else { throw new InvalidOperationException(ServicesErrorMessages.INVALID_JOB_OFFER); } } else { throw new InvalidOperationException(ServicesErrorMessages.INVALID_USER_ACCOUNT); } }
public async Task <JobOffer> GetJobOfferAsync(string id) { return(await _jobOfferRepository.GetByIdAsync(id)); }
public async Task SaveJobOffer_CreatesSuccessfullyANewJobOffer_WhenJobOfferDataIsCorrect() { //Arrange var skill1 = new Skill() { Name = "C#" }; var skill2 = new Skill() { Name = "Javascript" }; var skill3 = new Skill() { Name = "React" }; await _skillRepository.UpsertAsync(skill1); await _skillRepository.UpsertAsync(skill2); await _skillRepository.UpsertAsync(skill3); var recruiter = new Recruiter() { FirstName = "Maidana", LastName = "Patricia", IdentityCard = "28123456" }; await _recruiterService.CreateRecruiterAsync(recruiter); var company = new Company("Acme", "Software"); await _recruiterService.AddClientAsync(company, recruiter.Id); var jobOffer = await _recruiterService.GetNewJobOffer(recruiter.Id); jobOffer.Title = "Analista Funcional"; jobOffer.Description = "Se necesita analista funcional con bla bla bla"; jobOffer.RecruiterId = recruiter.Id; jobOffer.Date = DateTime.Now.Date; jobOffer.ContractInformation = new ContractCondition() { KindOfContract = "FullTime", StartingFrom = "As soon as possible", WorkingDays = "Montay to Friday" }; jobOffer.AddSkillRequired(new SkillRequired(skill1, 5, true)); jobOffer.AddSkillRequired(new SkillRequired(skill2, 4, false)); jobOffer.AddSkillRequired(new SkillRequired(skill3, 2, false)); jobOffer.CompanyId = company.Id; //Act await _recruiterService.SaveJobOfferAsync(jobOffer); var jobOfferSaved = await _jobOfferRepository.GetByIdAsync(jobOffer.Id); var companySaved = await _companyRepository.GetCompanyAsync(company.Name, company.Activity); //Assert Assert.AreEqual(companySaved.Id, jobOfferSaved.CompanyId, "The company created is different than the one assigned to the job offer"); Assert.AreEqual(jobOffer, jobOfferSaved, "Job offer was not saved"); Assert.AreEqual(JobOfferState.WorkInProgress, jobOfferSaved.State, "Job offer created has a wrong state"); Assert.AreEqual(recruiter.Id, jobOfferSaved.RecruiterId); }