public void TNP2RecordLaterThanTNP4Record_ReturnsEntity() { var tnp2Entity = new TestAppFinRecord { AFinType = "TNP", AFinCode = 2, AFinDate = new DateTime(2018, 10, 1) }; var tnp4Date = new DateTime(2018, 9, 1); var appFinRecords = new List <TestAppFinRecord> { tnp2Entity, }; var appFinRecordQueryServiceMock = new Mock <ILearningDeliveryAppFinRecordQueryService>(); appFinRecordQueryServiceMock.Setup(x => x.GetAppFinRecordsForTypeAndCode(appFinRecords, "TNP", 2)).Returns(appFinRecords); NewRule(appFinRecordQueryServiceMock.Object).TNP2RecordLaterThanTNP4Record(appFinRecords, tnp4Date).Should().Be(tnp2Entity); }
public void HasAnyLearningDeliveryAFinCodesForType_False_Mismatch() { var learningDeliveryAppFinRecords = new TestAppFinRecord[] { new TestAppFinRecord() { AFinType = "TypeOne", AFinCode = 1 }, new TestAppFinRecord() { AFinType = "TypeTwo", AFinCode = 2 }, new TestAppFinRecord() { AFinType = "TypeTwo", AFinCode = 3 }, }; var codes = new int[] { 2, 3 }; NewService().HasAnyLearningDeliveryAFinCodesForType(learningDeliveryAppFinRecords, "TypeOne", codes).Should().BeFalse(); }
public void HasAnyLearningDeliveryAFinCodes_False() { var appFinRecords = new TestAppFinRecord[] { new TestAppFinRecord() { AFinCode = 1 }, new TestAppFinRecord() { AFinCode = 2 }, new TestAppFinRecord() { AFinCode = 3 }, }; var codes = new int[] { 4, 5 }; NewService().HasAnyLearningDeliveryAFinCodes(appFinRecords, codes).Should().BeFalse(); }
public void TNP2DateEqualToTNP4Date_ReturnsEntity() { var tnp2Entity = new TestAppFinRecord { AFinType = "TNP", AFinCode = 2, AFinDate = new DateTime(2018, 9, 1) }; var tnp4Entity = new TestAppFinRecord { AFinType = "TNP", AFinCode = 4, AFinDate = new DateTime(2018, 9, 1) }; var appFinRecords = new List <TestAppFinRecord> { tnp2Entity, tnp4Entity }; NewRule().TNP2DateEqualToTNP4Date(appFinRecords).Should().Be(tnp2Entity); }
public void TNP1RecordLaterThanTNP3Record_ReturnsEntity() { var tnp1Entity = new TestAppFinRecord { AFinType = "TNP", AFinCode = 1, AFinDate = new DateTime(2018, 10, 1) }; var tnp3Entity = new TestAppFinRecord { AFinType = "TNP", AFinCode = 3, AFinDate = new DateTime(2018, 9, 1) }; var appFinRecords = new List <TestAppFinRecord> { tnp1Entity, tnp3Entity }; NewRule().TNP1RecordLaterThanTNP3Record(appFinRecords).Should().Be(tnp1Entity); }
public void Validate_NoError_AppFinRecordsDateMisMatch() { var tnp1ListOne = new List <TestAppFinRecord> { new TestAppFinRecord { AFinType = "TNP", AFinCode = 1, AFinDate = new DateTime(2018, 9, 1) }, new TestAppFinRecord { AFinType = "TNP", AFinCode = 1, AFinDate = new DateTime(2018, 10, 1) } }; var appFinRecordsOne = new List <TestAppFinRecord> { new TestAppFinRecord { AFinType = "PMR", AFinCode = 1, AFinDate = new DateTime(2018, 9, 1) } }; appFinRecordsOne.AddRange(tnp1ListOne); var tnp3 = new TestAppFinRecord { AFinType = "TNP", AFinCode = 3, AFinDate = new DateTime(2018, 10, 1) }; var tnp1ListTwo = new List <TestAppFinRecord> { new TestAppFinRecord { AFinType = "TNP", AFinCode = 1, AFinDate = new DateTime(2018, 10, 1) } }; var appFinRecordsTwo = new List <TestAppFinRecord> { new TestAppFinRecord { AFinType = "PMR", AFinCode = 1, AFinDate = new DateTime(2018, 9, 1) } }; appFinRecordsTwo.AddRange(tnp1ListTwo); appFinRecordsTwo.Add(tnp3); var learner = new TestLearner() { LearningDeliveries = new List <TestLearningDelivery>() { new TestLearningDelivery() { AppFinRecords = appFinRecordsOne }, new TestLearningDelivery() { AppFinRecords = appFinRecordsTwo } } }; var appFinRecordQueryServiceMock = new Mock <ILearningDeliveryAppFinRecordQueryService>(); appFinRecordQueryServiceMock.Setup(x => x.GetLatestAppFinRecord(appFinRecordsOne, "TNP", 3)).Returns((IAppFinRecord)null); appFinRecordQueryServiceMock.Setup(x => x.GetLatestAppFinRecord(appFinRecordsTwo, "TNP", 3)).Returns(tnp3); appFinRecordQueryServiceMock.Setup(x => x.GetAppFinRecordsForTypeAndCode(appFinRecordsOne, "TNP", 1)).Returns(tnp1ListOne); appFinRecordQueryServiceMock.Setup(x => x.GetAppFinRecordsForTypeAndCode(appFinRecordsTwo, "TNP", 1)).Returns(tnp1ListTwo); using (var validationErrorHandlerMock = BuildValidationErrorHandlerMockForNoError()) { NewRule(appFinRecordQueryServiceMock.Object, validationErrorHandlerMock.Object).Validate(learner); } }
public void Validate_Error() { var tnp2ListOne = new List <TestAppFinRecord> { new TestAppFinRecord { AFinType = "TNP", AFinCode = 2, AFinDate = new DateTime(2018, 9, 1) }, new TestAppFinRecord { AFinType = "TNP", AFinCode = 2, AFinDate = new DateTime(2018, 10, 1) }, }; var appFinListOne = new List <TestAppFinRecord>(); appFinListOne.Union(tnp2ListOne); appFinListOne.Add( new TestAppFinRecord { AFinType = "PMR", AFinCode = 2, AFinDate = new DateTime(2018, 9, 1) }); var tnp2ListTwo = new List <TestAppFinRecord> { new TestAppFinRecord { AFinType = "TNP", AFinCode = 2, AFinDate = new DateTime(2018, 11, 1) } }; var tnp4Two = new TestAppFinRecord { AFinType = "TNP", AFinCode = 4, AFinDate = new DateTime(2018, 10, 1) }; var appFinListTwo = new List <TestAppFinRecord> { new TestAppFinRecord { AFinType = "PMR", AFinCode = 2, AFinDate = new DateTime(2018, 9, 1) } }; appFinListTwo.Union(tnp2ListTwo); appFinListTwo.Add(tnp4Two); var learner = new TestLearner() { LearningDeliveries = new List <TestLearningDelivery>() { new TestLearningDelivery() { AppFinRecords = appFinListOne }, new TestLearningDelivery() { AppFinRecords = appFinListTwo } } }; var appFinRecordQueryServiceMock = new Mock <ILearningDeliveryAppFinRecordQueryService>(); appFinRecordQueryServiceMock.Setup(x => x.GetLatestAppFinRecord(appFinListOne, "TNP", 4)).Returns((IAppFinRecord)null); appFinRecordQueryServiceMock.Setup(x => x.GetLatestAppFinRecord(appFinListTwo, "TNP", 4)).Returns(tnp4Two); appFinRecordQueryServiceMock.Setup(x => x.GetAppFinRecordsForTypeAndCode(appFinListOne, "TNP", 2)).Returns(tnp2ListOne); appFinRecordQueryServiceMock.Setup(x => x.GetAppFinRecordsForTypeAndCode(appFinListTwo, "TNP", 2)).Returns(tnp2ListTwo); using (var validationErrorHandlerMock = BuildValidationErrorHandlerMockForError()) { NewRule(appFinRecordQueryServiceMock.Object, validationErrorHandlerMock.Object).Validate(learner); } }
public void IsTotalNegotiatedPriceMoreThanCapForStandards_True() { var appFinRecord1 = new TestAppFinRecord { AFinCode = 1, AFinType = "TNP", AFinAmount = 15, AFinDate = new DateTime(2017, 01, 01) }; var appFinRecord2 = new TestAppFinRecord { AFinCode = 2, AFinType = "TNP", AFinAmount = 10, AFinDate = new DateTime(2017, 01, 01) }; var learningDeliveries = new List <ILearningDelivery>() { new TestLearningDelivery() { StdCodeNullable = 50, AimType = TypeOfAim.ComponentAimInAProgramme, FundModel = 81, ProgTypeNullable = 25, AppFinRecords = new List <IAppFinRecord>() { appFinRecord1, appFinRecord2 } }, new TestLearningDelivery() { StdCodeNullable = 1, AimType = TypeOfAim.ProgrammeAim, ProgTypeNullable = 25, FundModel = 81, AppFinRecords = new List <IAppFinRecord>() { appFinRecord1, appFinRecord2 } }, new TestLearningDelivery() { StdCodeNullable = 1, AimType = TypeOfAim.ProgrammeAim, ProgTypeNullable = 25, FundModel = 81, AppFinRecords = new List <IAppFinRecord>() { appFinRecord1, appFinRecord2 } } }; var learningDeliveryAppFinRecordQueryServiceMock = new Mock <ILearningDeliveryAppFinRecordQueryService>(); learningDeliveryAppFinRecordQueryServiceMock .Setup(x => x.GetTotalTNPPriceForLatestAppFinRecordsForLearning(It.IsAny <List <ILearningDelivery> >())).Returns(50); var larsDataServiceMock = new Mock <ILARSDataService>(); larsDataServiceMock .Setup(x => x.GetStandardFundingForCodeOnDate(1, It.IsAny <DateTime>())).Returns(new LARSStandardFunding() { CoreGovContributionCap = 1m }); NewRule(larsDataServiceMock.Object, learningDeliveryAppFinRecordQueryServiceMock.Object) .IsTotalNegotiatedPriceMoreThanCapForStandard(learningDeliveries, 1).Should().BeTrue(); NewRule(larsDataServiceMock.Object, learningDeliveryAppFinRecordQueryServiceMock.Object) .IsTotalNegotiatedPriceMoreThanCapForStandard(learningDeliveries, 50).Should().BeFalse(); }