public async Task SaveJobOfferAsync_StoreDataInDB_WhenJobOfferIsValid() { //Arrange var jobOffer = new JobOffer { ContractInformation = new ContractCondition() { KindOfContract = "FullTime", StartingFrom = "As soon as possible", WorkingDays = "Montay to Friday" }, RecruiterId = Guid.NewGuid().ToString(), CompanyId = Guid.NewGuid().ToString() }; _recruiterRepositoryMock.Setup(mock => mock.CheckEntityExistsAsync(It.IsAny <string>())).ReturnsAsync(true); _companyRepositoryMock.Setup(mock => mock.CheckEntityExistsAsync(It.IsAny <string>())).ReturnsAsync(true); _jobOfferRepositoryMock.Setup(mock => mock.JobOfferBelongsToRecruiter(It.IsAny <JobOffer>())).Returns(Task.FromResult <bool>(true)); _jobOfferRepositoryMock.Setup(mock => mock.CheckEntityExistsAsync(It.IsAny <string>())).ReturnsAsync(true); _jobOfferRepositoryMock.Setup(mock => mock.UpsertAsync(It.IsAny <JobOffer>())).Returns(Task.CompletedTask); //Act await _service.SaveJobOfferAsync(jobOffer); //Assert _jobOfferRepositoryMock.VerifyAll(); }
public async Task SaveJobOffer([FromBody] JobOffer jobOffer) { await _recruiterService.SaveJobOfferAsync(jobOffer); }
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); }
private static void Main(string[] args) { var mongoClient = new MongoClient(); mongoClient.DropDatabase("JobOfferDatabase"); var database = mongoClient.GetDatabase("JobOfferDatabase"); var cSharp = new Skill() { Name = "C#" }; var javascript = new Skill() { Name = "Javascript" }; var react = new Skill() { Name = "React" }; var docker = new Skill() { Name = "Docker" }; var java = new Skill() { Name = "Java" }; var skillRepository = new SkillRepository(database); Task.Run(async() => await skillRepository.UpsertAsync(cSharp)).Wait(); Task.Run(async() => await skillRepository.UpsertAsync(javascript)).Wait(); Task.Run(async() => await skillRepository.UpsertAsync(react)).Wait(); Task.Run(async() => await skillRepository.UpsertAsync(docker)).Wait(); Task.Run(async() => await skillRepository.UpsertAsync(java)).Wait(); var companyRepository = new CompanyRepository(database); var recruiterRepository = new RecruiterRepository(database); var jobOfferRepository = new JobOfferRepository(database); var personRepository = new PersonRepository(database); var accountRepository = new AccountRepository(database); var recruiterService = new RecruiterService(companyRepository, recruiterRepository, jobOfferRepository, personRepository, accountRepository); var recruiter = new Recruiter(); recruiter.AddClient(new Company("Acme", "Software")); recruiter.IdentityCard = "28.999.999"; recruiter.FirstName = "Patricia"; recruiter.LastName = "Maidana"; recruiter.SetStudy(new Study("UBA", "Lic.RRHH", StudyStatus.Completed)); recruiter.SetPreviousJob(new Job("Coto", "HR Analyst", DateTime.Now.AddYears(-6), true)); recruiter.SetAbility(new Ability(javascript, 9)); var company1 = new Company("Acme", "software"); companyRepository.UpsertAsync(company1).Wait(); recruiterService.CreateRecruiterAsync(recruiter).Wait(); var jobOffer = Task.Run(() => { RecruiterService recruiterService1 = recruiterService; return(recruiterService1.GetNewJobOffer(recruiter.Id)); }).Result; jobOffer.Date = DateTime.Now.Date; jobOffer.Title = "Analista programador"; jobOffer.CompanyId = company1.Id; jobOffer.Zone = "Palermo"; jobOffer.Description = "Para importante empresa ubicada en San Telmo, estamos en búsqueda de desarrollador fullstack con " + "al menos 3 años de experiencia utilizando React y NodeJs.Quien se incorpore estará participando dentro " + "de un proyecto de inteligencia artifical"; jobOffer.AddSkillRequired(new SkillRequired(javascript, 5, true)); jobOffer.AddSkillRequired(new SkillRequired(react, 3)); jobOffer.Language = "Ingles"; jobOffer.LanguageLevel = LanguageLevel.Advance; jobOffer.IsLanguageMandatory = true; jobOffer.ContractInformation = new ContractCondition() { StartingFrom = "Inmediata", KindOfContract = "Relación de dependencia", WorkingDays = "Lunes a viernes 9 a 18" }; recruiterService.SaveJobOfferAsync(jobOffer).Wait(); // var company2 = new Company("KaizenRH", "software"); companyRepository.UpsertAsync(company2).Wait(); var jobOffer2 = Task.Run(() => recruiterService.GetNewJobOffer(recruiter.Id)).Result; jobOffer2.Date = DateTime.Now.Date; jobOffer2.Title = "JAVA Full Stack Developer"; jobOffer2.CompanyId = company2.Id; jobOffer2.Zone = "Las Cañitas"; jobOffer2.Description = "En KaizenRH buscamos Python Developer Junior para trabajar en interesantes proyectos dentro de Startup en expansión LATAM dedicada a la automatización de procesos IT y negocios."; jobOffer2.AddSkillRequired(new SkillRequired(javascript, 5, true)); jobOffer2.AddSkillRequired(new SkillRequired(react, 3)); jobOffer2.AddSkillRequired(new SkillRequired(java, 6, true)); jobOffer2.Language = "Ingles"; jobOffer2.LanguageLevel = LanguageLevel.Intermediate; jobOffer2.ContractInformation = new ContractCondition() { StartingFrom = "Inmediata", KindOfContract = "Relación de dependencia", WorkingDays = "Lunes a viernes 9 a 18" }; recruiterService.SaveJobOfferAsync(jobOffer2).Wait(); // var company3 = new Company("ADN Recursos Humanos", "Seleccion de personal"); companyRepository.UpsertAsync(company3).Wait(); var jobOffer3 = Task.Run(() => recruiterService.GetNewJobOffer(recruiter.Id)).Result; jobOffer3.Date = DateTime.Now.Date; jobOffer3.Title = "Sr. C# Backend Developer/Engineer"; jobOffer3.CompanyId = company3.Id; jobOffer3.Zone = "Microcentro"; jobOffer3.Description = "ADN - Recursos Humanos estamos en la búsqueda de un Sr. Python Backend Developer/Engineer, para Importante Empresa de Tecnología"; jobOffer3.AddSkillRequired(new SkillRequired(cSharp, 5)); jobOffer3.AddSkillRequired(new SkillRequired(javascript, 2, true)); jobOffer3.ContractInformation = new ContractCondition() { StartingFrom = "Inmediata", KindOfContract = "Relación de dependencia", WorkingDays = "Lunes a viernes 9 a 18" }; recruiterService.SaveJobOfferAsync(jobOffer3).Wait(); recruiterService.PublishJobOffer(jobOffer2).Wait(); recruiterService.PublishJobOffer(jobOffer3).Wait(); recruiterService.FinishJobOffer(jobOffer3).Wait(); var pRepo = new RecruiterRepository(database); var aRepo = new AccountRepository(database); var person = pRepo.GetByIdentityCardAsync("28.999.999").Result; var account = new Account() { Id = Guid.NewGuid().ToString(), PersonId = person.Id, Email = "*****@*****.**", Password = "******", IsRecruiter = true }; aRepo.UpsertAsync(account).Wait(); Console.WriteLine("Agregado correctamente!"); Console.ReadKey(); }