public void CreateSocSkillsMatrixRecordsTest(int numberOfSocSkills) { // Arrange var skillsImportService = new SkillsFrameworkDataImportService(fakeSkillsFrameworkService, fakeFrameworkSkillRepository, fakeJobProfileSocCodeRepository, fakeJobProfileRepository, fakeSocSkillMatrixRepository, fakeReportAuditRepository); //Dummies and Fakes A.CallTo(() => fakeSkillsFrameworkService.GetRelatedSkillMapping(A <string> ._)).Returns(GetRelatedSkill(numberOfSocSkills)); A.CallTo(() => fakeSocSkillMatrixRepository.UpsertSocSkillMatrix(A <SocSkillMatrix> ._)).DoesNothing(); // Act skillsImportService.CreateSocSkillsMatrixRecords(new SocCode { SOCCode = "dummySOC" }); // Assert A.CallTo(() => fakeSkillsFrameworkService.GetRelatedSkillMapping(A <string> ._)).MustHaveHappenedOnceExactly(); A.CallTo(() => fakeReportAuditRepository.CreateAudit("ActionDetails", A <string> ._)).MustHaveHappened((numberOfSocSkills + 1), Times.Exactly); A.CallTo(() => fakeSocSkillMatrixRepository.UpsertSocSkillMatrix(A <SocSkillMatrix> ._)).MustHaveHappened(numberOfSocSkills, Times.Exactly); if (numberOfSocSkills == 0) { A.CallTo(() => fakeReportAuditRepository.CreateAudit("ErrorDetails", A <string> ._)).MustHaveHappened(); } }
public IList <SocSkillMatrix> CreateSocSkillsMatrixRecords(SocCode soc) { if (soc == null) { throw new ArgumentNullException(nameof(soc)); } var occupationSkills = skillsFrameworkService.GetRelatedSkillMapping(soc.ONetOccupationalCode); //Create SOC skill matrix records reportAuditRepository.CreateAudit(ActionDetailsKey, $"Found {occupationSkills.Count()} Skills for {soc.ONetOccupationalCode} SOC {soc.SOCCode} from SkillFramework Service"); //Save it as an error as well if (occupationSkills.Count() == 0) { reportAuditRepository.CreateAudit(ErrorDetailsKey, $"Found {occupationSkills.Count()} Skills for {soc.ONetOccupationalCode} SOC {soc.SOCCode} from SkillFramework Service"); } var rankGenerated = 1; var socSkillMatrixData = new List <SocSkillMatrix>(); foreach (var occupationSkill in occupationSkills) { var socSkillToAdd = new SocSkillMatrix { Title = $"{soc.SOCCode}-{occupationSkill.Name}", SocCode = soc.SOCCode, Skill = occupationSkill.Name, ONetRank = occupationSkill.Score, Rank = rankGenerated, ONetElementId = occupationSkill.Id, ONetAttributeType = occupationSkill.Category.ToString() }; socSkillMatrixRepository.UpsertSocSkillMatrix(socSkillToAdd); socSkillMatrixData.Add(socSkillToAdd); reportAuditRepository.CreateAudit(ActionDetailsKey, $"Added/Updated Soc Skill Matrix profile {socSkillToAdd.Title} into socskill matrix repo"); rankGenerated++; } return(socSkillMatrixData); }