public MessageLearnerDestinationandProgression Process(MessageLearnerDestinationandProgression model) { model.LearnRefNumber = _learnerRefProvider.ProvideNewReference(model.LearnRefNumber, true); if (model.ULN.HasValue) { model.ULN = _ulnProvider.ProvideNewReference(model.ULN.Value, true); } return(model); }
public async Task ProvideAsync_MultipleShards() { var testLearners = new MessageLearner[] { new MessageLearner { LearnRefNumber = "Learner1" }, new MessageLearner { LearnRefNumber = "Learner2" }, }; var testLearnerDP = new MessageLearnerDestinationandProgression[] { new MessageLearnerDestinationandProgression { LearnRefNumber = "Learner1" }, new MessageLearnerDestinationandProgression { LearnRefNumber = "Learner2" }, }; IMessage message = new Message { Header = new MessageHeader(), LearnerDestinationandProgression = testLearnerDP, LearningProvider = new MessageLearningProvider { UKPRN = 12345678 }, }; var messages = new List <IMessage> { message }; var messageCacheMock = new Mock <ICache <IMessage> >(); messageCacheMock.SetupGet(mc => mc.Item).Returns(message); var learnerDPPerActorProviderServiceMock = new Mock <LearnerDPPerActorProviderService>(messageCacheMock.Object); learnerDPPerActorProviderServiceMock.Setup(ss => ss.CalculateLearnerDPsPerActor(message.LearnerDestinationAndProgressions.Count)).Returns(1); var lpa = (await learnerDPPerActorProviderServiceMock.Object.ProvideAsync()).ToArray(); lpa.Select(m => m).Should().HaveCount(2); lpa[0].Learners.Should().BeNullOrEmpty(); lpa[1].Learners.Should().BeNullOrEmpty(); lpa[0].LearnerDestinationAndProgressions.Should().HaveCount(1); lpa[1].LearnerDestinationAndProgressions.Should().HaveCount(1); }
public void ApplyFilter_LearnerDestinationAndProgression() { var invalidLearnerOneLearnRefNumber = "InvalidOne"; var invalidLearnerOne = new MessageLearnerDestinationandProgression() { LearnRefNumber = invalidLearnerOneLearnRefNumber }; var invalidLearnerTwoLearnRefNumber = "InvalidTwo"; var invalidLearnerTwo = new MessageLearnerDestinationandProgression() { LearnRefNumber = invalidLearnerTwoLearnRefNumber }; var validLearnerThreeLearnRefNumber = "ValidThree"; var validLearnerThree = new MessageLearnerDestinationandProgression() { LearnRefNumber = validLearnerThreeLearnRefNumber }; var message = new Message() { LearnerDestinationandProgression = new[] { invalidLearnerOne, invalidLearnerTwo, validLearnerThree, } }; var validationErrors = new List <IValidationError>() { new ValidationError.Model.ValidationError() { LearnerReferenceNumber = invalidLearnerOneLearnRefNumber, Severity = Severity.Error }, new ValidationError.Model.ValidationError() { LearnerReferenceNumber = invalidLearnerTwoLearnRefNumber, Severity = Severity.Error }, new ValidationError.Model.ValidationError() { LearnerReferenceNumber = invalidLearnerOneLearnRefNumber, Severity = Severity.Error }, new ValidationError.Model.ValidationError() { LearnerReferenceNumber = validLearnerThreeLearnRefNumber, Severity = Severity.Warning }, }; var validMessage = NewService().ApplyFilter(message, validationErrors); validMessage.LearnerDestinationandProgression.Should().Contain(validLearnerThree); validMessage.LearnerDestinationandProgression.Should().HaveCount(1); }
public async Task ProvideAsync_LearnerDPMismatch() { var testLearners = new MessageLearner[] { new MessageLearner { LearnRefNumber = "Learner1" }, new MessageLearner { LearnRefNumber = "Learner2" }, }; var testLearnerDP = new MessageLearnerDestinationandProgression[] { new MessageLearnerDestinationandProgression { LearnRefNumber = "Learner1" }, new MessageLearnerDestinationandProgression { LearnRefNumber = "Learner3" }, }; IMessage message = new Message { Header = new MessageHeader(), Learner = testLearners, LearnerDestinationandProgression = testLearnerDP, LearningProvider = new MessageLearningProvider { UKPRN = 12345678 }, }; var messages = new List <IMessage> { message }; var messageCacheMock = new Mock <ICache <IMessage> >(); messageCacheMock.SetupGet(mc => mc.Item).Returns(message); var learnerPerActorProviderService = new LearnerPerActorProviderService(messageCacheMock.Object); var lpa = await learnerPerActorProviderService.ProvideAsync(); lpa.Select(m => m).Should().HaveCount(1); lpa.SelectMany(m => m.Learners).Should().HaveCount(2); lpa.SelectMany(m => m.LearnerDestinationAndProgressions).Should().HaveCount(1); }
public async Task ProvideAsync() { var testLearners = new MessageLearner[] { new MessageLearner { LearnRefNumber = "Learner1" }, new MessageLearner { LearnRefNumber = "Learner2" }, }; var testLearnerDP = new MessageLearnerDestinationandProgression[] { new MessageLearnerDestinationandProgression { LearnRefNumber = "Learner1" }, new MessageLearnerDestinationandProgression { LearnRefNumber = "Learner2" }, }; IMessage message = new Message { Header = new MessageHeader(), Learner = testLearners, LearnerDestinationandProgression = testLearnerDP, LearningProvider = new MessageLearningProvider { UKPRN = 12345678 }, }; var messages = new List <IMessage> { message }; var messageCacheMock = new Mock <ICache <IMessage> >(); messageCacheMock.SetupGet(mc => mc.Item).Returns(message); var learnerPerActorProviderService = new LearnerPerActorProviderService(messageCacheMock.Object); (await learnerPerActorProviderService.ProvideAsync()).Should().BeEquivalentTo(messages); }
public void ProvideAsync() { var testLearners = new MessageLearner[] { new MessageLearner { LearnRefNumber = "Learner1" }, new MessageLearner { LearnRefNumber = "Learner2" }, }; var testLearnerDP = new MessageLearnerDestinationandProgression[] { new MessageLearnerDestinationandProgression { LearnRefNumber = "Learner1" }, new MessageLearnerDestinationandProgression { LearnRefNumber = "Learner2" }, }; IMessage message = new Message { Header = new MessageHeader(), LearnerDestinationandProgression = testLearnerDP, LearningProvider = new MessageLearningProvider { UKPRN = 12345678 }, }; var messages = new List <IMessage> { message }; var learnerDPPerActorProviderServiceMock = new LearnerDPPerActorProviderService(); learnerDPPerActorProviderServiceMock.Provide(message).Should().BeEquivalentTo(messages); }
public void Provide_LearnerDPNoMatch() { var testLearners = new MessageLearner[] { new MessageLearner { LearnRefNumber = "Learner1" }, new MessageLearner { LearnRefNumber = "Learner2" }, }; var testLearnerDP = new MessageLearnerDestinationandProgression[] { new MessageLearnerDestinationandProgression { LearnRefNumber = "Learner3" }, new MessageLearnerDestinationandProgression { LearnRefNumber = "Learner4" }, }; IMessage message = new Message { Header = new MessageHeader(), Learner = testLearners, LearnerDestinationandProgression = testLearnerDP, LearningProvider = new MessageLearningProvider { UKPRN = 12345678 }, }; var learnerPerActorProviderService = new LearnerPerActorProviderService(); var lpa = learnerPerActorProviderService.Provide(message); lpa.Select(m => m).Should().HaveCount(1); lpa.SelectMany(m => m.Learners).Should().HaveCount(2); lpa.SelectMany(m => m.LearnerDestinationAndProgressions).Should().HaveCount(0); }
public void Provide_MultipleShards() { var testLearners = new List <MessageLearner>(); for (var i = 0; i < 1001; i++) { testLearners.Add(new MessageLearner()); } ; var testLearnerDP = new MessageLearnerDestinationandProgression[] { new MessageLearnerDestinationandProgression { LearnRefNumber = "Learner1" }, new MessageLearnerDestinationandProgression { LearnRefNumber = "Learner2" }, }; IMessage message = new Message { Header = new MessageHeader(), Learner = testLearners.ToArray(), LearnerDestinationandProgression = testLearnerDP, LearningProvider = new MessageLearningProvider { UKPRN = 12345678 }, }; var messageCacheMock = new Mock <ICache <IMessage> >(); messageCacheMock.SetupGet(mc => mc.Item).Returns(message); var lpa = new LearnerPerActorProviderService().Provide(message).ToArray(); lpa.Select(m => m).Should().HaveCount(2); lpa[0].Learners.Should().HaveCount(1000); lpa[1].Learners.Should().HaveCount(1); }
private void MutateProgression(MessageLearnerDestinationandProgression learner, bool valid) { learner.DPOutcome[0].OutType = OutcomeType.EDU.ToString(); learner.DPOutcome[0].OutCode = (int)OutcomeCode.EDU_Apprenticeship; }
internal int GenerateAndMutate( string ruleName, bool valid, int currentLearnerIndex, List <XmlTriplet> triplets, ref long ULNIndex) { XmlTriplet triplet = triplets.First(); int result = 0; LearnerGenerator lg = new LearnerGenerator(_cache); foreach (var functor in _ruleFunctors[ruleName]) { foreach (var funcy in functor.LearnerMutators(_cache)) { GenerationOptions options = lg.CreateGenerationOptions(funcy.LearnerType); funcy.DoMutateOptions(options); if (options.OverrideUKPRN.HasValue) { var ftrip = triplets.Where(s => s.UKPRN == options.OverrideUKPRN.Value); if (ftrip.Count() == 0) { triplet = new XmlTriplet() { UKPRN = options.OverrideUKPRN.Value }; triplets.Add(triplet); } } else { triplet = triplets.First(); } lg.Options = options; List <MessageLearner> generated = lg.Generate(ruleName, funcy.LearnerType, currentLearnerIndex, ref ULNIndex); generated.ForEach(s => { triplet.FileRuleLearners.Add(new FileRuleLearner() { ExclusionRecord = funcy.ExclusionRecord, RuleName = ruleName, LearnRefNumber = s.LearnRefNumber, ValidLines = funcy.ValidLines, InvalidLines = funcy.InvalidLines, Valid = valid }); funcy.DoMutateLearner(s, valid); if (lg.Options.CreateDestinationAndProgression) { MessageLearnerDestinationandProgression prog = lg.GenerateProgression(ruleName, s); funcy.DoMutateProgression?.Invoke(prog, valid); triplet.Progressions.Add(prog); } }); triplet.Learners.AddRange(generated); currentLearnerIndex += generated.Count; result += generated.Count; } } return(result); }