public void AddSkillRequired_ThrowsException_WhenThereIsASkillRequiredRepeated() { //Arrange var contractCondition = new ContractCondition() { KindOfContract = "a", StartingFrom = "b", WorkingDays = "c" }; var jobOffer = new JobOffer() { Title = "Some title", ContractInformation = contractCondition }; var javascript = new Skill() { Id = Guid.NewGuid().ToString(), Name = "Javascript" }; var skillRequired = new SkillRequired(javascript, 1); jobOffer.AddSkillRequired(skillRequired); //Act try { jobOffer.AddSkillRequired(skillRequired); } catch (InvalidOperationException ex) { Assert.AreEqual(ex.Message, DomainErrorMessages.SKILL_REQUIRED_ALREADY_EXISTS); } }
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 void RecieveApplicant_ThrowsInvalidOperationException_WhenApplicantAlreadyExists() { //Arrange var skill = new Skill() { Name = "C#", Id = Guid.NewGuid().ToString() }; var person = new Person() { FirstName = "Pepe", LastName = "Lopez", IdentityCard = "123" }; person.SetAbility(new Ability(skill, 5)); var jobOffer = new JobOffer(); jobOffer.AddSkillRequired(new SkillRequired(skill, 3, true)); jobOffer.AddJobApplicationRequested(person); //Act try { jobOffer.AddJobApplicationRequested(person); Assert.Fail("Job offer shoud throw exeption when a person tries to apply more than one time"); } catch (InvalidOperationException ex) { Assert.AreEqual(ex.Message, DomainErrorMessages.APPLICANT_ALREADY_REQUESTED_JOB_OFFER); } }
public void RecieveApplicant_CreatesJobApplication_WhenItIsTheFirstAttemptToApply() { //Arrange var skill = new Skill() { Name = "C#", Id = Guid.NewGuid().ToString() }; var person = new Person() { FirstName = "Pepe", LastName = "Lopez", IdentityCard = "123" }; person.SetAbility(new Ability(skill, 5)); var jobOffer = new JobOffer(); jobOffer.AddSkillRequired(new SkillRequired(skill, 3, true)); //Act jobOffer.AddJobApplicationRequested(person); var jobApplication = jobOffer.Applications.Where(a => a.ApplicantId == person.Id).SingleOrDefault(); //Assert Assert.IsNotNull(jobApplication); }
public void OfferEmployment_CreatesANewJobApplication_AndSetItWithStatusOffered_WhenPersonHasTheRequiredSkills() { //Arrange var skillCSharp = new Skill() { Name = "C#", Id = Guid.NewGuid().ToString() }; var person = new Person() { FirstName = "Pepe", LastName = "Lopez", Id = Guid.NewGuid().ToString(), IdentityCard = "123" }; person.SetAbility(new Ability(skillCSharp, 5)); var jobOffer = new JobOffer() { Id = Guid.NewGuid().ToString() }; jobOffer.AddSkillRequired(new SkillRequired(skillCSharp, 3, true)); var recruiter = new Recruiter(); //Act recruiter.OfferEmployment(jobOffer, person); //Assert Assert.IsTrue(jobOffer.Applications.First().Progress.Count() == 2); Assert.IsTrue(jobOffer.Applications.First().Progress.First().State == ApplicationState.Recieved); Assert.IsTrue(jobOffer.Applications.First().Progress.Last().State == ApplicationState.Offered); }
public void ApplyToJobOffer_CreatesNewJobApplication_OnAJobOffer() { //Arrange var skill = new Skill() { Name = "C#", Id = Guid.NewGuid().ToString() }; var person = new Person() { FirstName = "Pepe", LastName = "Lopez", IdentityCard = "123" }; person.SetAbility(new Ability(skill, 5)); var jobOffer = new JobOffer(); jobOffer.AddSkillRequired(new SkillRequired(skill, 3, true)); //Act person.ApplyToJobOffer(jobOffer); var jobApplication = jobOffer.Applications.Where(a => a.ApplicantId == person.Id).SingleOrDefault(); //Assert Assert.IsTrue(jobApplication.Progress.Count() == 2); Assert.IsTrue(jobApplication.Progress.First().State == ApplicationState.Recieved); Assert.IsTrue(jobApplication.Progress.Last().State == ApplicationState.Requested); }
public void AcceptApplicant_CreatesANewProgress_OnJobApplication() { //Arrange var person = new Person() { FirstName = "Pepe", LastName = "Lopez" }; person.SetAbility(new Ability(new Skill() { Name = "C#" }, 5)); var jobOffer = new JobOffer(); jobOffer.AddSkillRequired(new SkillRequired(new Skill() { Name = "C#" }, 3, true)); person.ApplyToJobOffer(jobOffer); //Act jobOffer.AcceptApplicant(person); var jobApplication = jobOffer.Applications.Where(a => a.Applicant == person).SingleOrDefault(); //Assert Assert.IsTrue(jobApplication.Progress.Count() == 2); Assert.IsTrue(jobApplication.Progress.Last().State == ApplicationState.Accepted); }
public async Task ApplyToJobOffer_CreateNewJobApplication_AndLinkItToThePerson_WhenPersonHasSkillsRequired() { //Arrange _accountRepositoryMock.Setup(mock => mock.GetByIdAsync(It.IsAny <string>())).ReturnsAsync(new Account()); var jobOffer = new JobOffer(); var cSharp = new Skill() { Id = Guid.NewGuid().ToString(), Name = "C#" }; var mongoDB = new Skill() { Id = Guid.NewGuid().ToString(), Name = "MongoDb" }; jobOffer.AddSkillRequired(new SkillRequired(cSharp, 3, true)); jobOffer.AddSkillRequired(new SkillRequired(mongoDB, 2)); _jobOfferRepositoryMock.Setup(mock => mock.GetByIdAsync(It.IsAny <string>())).ReturnsAsync(jobOffer); var person = new Person() { IdentityCard = "123", Id = Guid.NewGuid().ToString(), FirstName = "Pepe", LastName = "Lopez" }; person.SetAbility(new Ability(cSharp, 5)); person.SetAbility(new Ability(mongoDB, 1)); _personRepositoryMock.Setup(mock => mock.GetByIdAsync(It.IsAny <string>())).ReturnsAsync(person); _jobOfferRepositoryMock.Setup(mock => mock.UpsertAsync(It.IsAny <JobOffer>())).Returns(Task.CompletedTask); _personRepositoryMock.Setup(mock => mock.UpsertAsync(It.IsAny <Person>())).Returns(Task.CompletedTask); //Act await _personService.ApplyToJobOfferAsync(It.IsAny <string>(), It.IsAny <string>()); //Accert _jobOfferRepositoryMock.VerifyAll(); _personRepositoryMock.VerifyAll(); Assert.AreEqual(person.Id, jobOffer.Applications.First().ApplicantId, "The new Job Application should have as applicant the same ID than the person who is applying"); }
public void AddSkillRequired_AcceptsSkill_WhenJobSkillDoesNotExists() { //Arrange var jobOffer = new JobOffer(); var cSharp = new Skill() { Name = "C#", Id = Guid.NewGuid().ToString() }; var javascript = new Skill() { Name = "Javascript", Id = Guid.NewGuid().ToString() }; jobOffer.AddSkillRequired(new SkillRequired(cSharp, 3, true)); //Act jobOffer.AddSkillRequired(new SkillRequired(javascript, 5, false)); Assert.AreEqual(2, jobOffer.SkillsRequired.Count()); }
public void AddSkillRequired_ThrowsInvalidOperationException_WhenJobSkillAlreadyExists() { //Arrange var jobOffer = new JobOffer(); var skill = new Skill() { Name = "C#", Id = Guid.NewGuid().ToString() }; jobOffer.AddSkillRequired(new SkillRequired(skill, 3, true)); //Act try { jobOffer.AddSkillRequired(new SkillRequired(skill, 5, false)); Assert.Fail("It shouldn't allow to add a repeated skill"); } catch (InvalidOperationException ex) { Assert.AreEqual(ex.Message, DomainErrorMessages.SKILL_REQUIRED_ALREADY_EXISTS); } }
public async Task GetJobOffersAsync_ReturnsAListWithJobOffersIndicatingWhichOneAreAlreadyApplied() { //Arrange var jobOffer1 = new JobOffer() { Id = Guid.NewGuid().ToString() }; var jobOffer2 = new JobOffer() { Id = Guid.NewGuid().ToString() }; var cSharp = new Skill() { Id = Guid.NewGuid().ToString(), Name = "C#" }; jobOffer1.AddSkillRequired(new SkillRequired(cSharp, 1, true)); var jobOffers = new List <JobOffer>() { jobOffer1, jobOffer2 }; var person = new Person() { Id = Guid.NewGuid().ToString(), IdentityCard = "123", FirstName = "Pepe", LastName = "Lopez" }; person.SetAbility(new Ability(cSharp, 3)); jobOffer1.AddJobApplicationOffered(person); person.ApplyToJobOffer(jobOffers.First()); _jobOfferRepositoryMock.Setup(mock => mock.GetAllPublishedJobOffersAsync()).ReturnsAsync(jobOffers); _personRepositoryMock.Setup(mock => mock.GetByIdAsync(It.IsAny <string>())).ReturnsAsync(person); //Act var result = await _service.GetJobOffersAsync(person.Id); //Assert Assert.IsTrue(result.Single(r => r.AlreadyApplied).JobOffer == jobOffer1, "JobOffers are not including the application that the person already did"); }
public void AcceptApplicant_CreatesNewApplication_OnAJobOffer() { //Arrange var skillCSharp = new Skill() { Name = "C#", Id = Guid.NewGuid().ToString() }; var person = new Person() { FirstName = "Pepe", LastName = "Lopez", Id = Guid.NewGuid().ToString(), IdentityCard = "123" }; person.SetAbility(new Ability(skillCSharp, 5)); var jobOffer = new JobOffer() { Id = Guid.NewGuid().ToString() }; jobOffer.AddSkillRequired(new SkillRequired(skillCSharp, 3, true)); person.ApplyToJobOffer(jobOffer); var recruiter = new Recruiter(); //Act recruiter.AcceptApplicant(person, jobOffer); var jobApplication = jobOffer.Applications.Where(a => a.ApplicantId == person.Id).SingleOrDefault(); //Assert Assert.IsTrue(jobApplication.Progress.Count() == 3); Assert.IsNotNull(jobApplication.Progress.SingleOrDefault(p => p.State == ApplicationState.Recieved)); Assert.IsNotNull(jobApplication.Progress.SingleOrDefault(p => p.State == ApplicationState.Requested)); Assert.IsNotNull(jobApplication.Progress.SingleOrDefault(p => p.State == ApplicationState.Accepted)); }