Exemplo n.º 1
0
 /// <summary>
 /// Determines whether [in qualifying period] [the specified delivery].
 /// TODO: needs to cater for 'termination' but this is currently a string of indeterminate quality
 /// It.IsBetween(delivery.LearnStartDate, onsPostcode.EffectiveFrom, onsPostcode.EffectiveTo ?? onsPostcode.Termination ?? DateTime.MaxValue);
 /// </summary>
 /// <param name="delivery">The delivery.</param>
 /// <param name="onsPostcode">The ons postcode.</param>
 /// <returns>
 ///   <c>true</c> if [in qualifying period] [the specified delivery]; otherwise, <c>false</c>.
 /// </returns>
 public bool InQualifyingPeriod(ILearningDelivery delivery, IONSPostcode onsPostcode) =>
 It.IsBetween(delivery.LearnStartDate, onsPostcode.EffectiveFrom, onsPostcode.Termination ?? onsPostcode.EffectiveTo ?? DateTime.MaxValue);
 public bool CheckQualifyingPeriod(DateTime?latestLearningStart, IONSPostcode onsPostCode) =>
 latestLearningStart <onsPostCode.EffectiveFrom ||
                      latestLearningStart> (onsPostCode.EffectiveTo ?? DateTime.MaxValue) ||
 latestLearningStart >= (onsPostCode.Termination ?? DateTime.MaxValue);
Exemplo n.º 3
0
        public void ValidItemDoesNotRaiseAValidationMessage(string startDate, string from, string to, string termination)
        {
            // arrange
            const string learnRefNumber = "123456789X";
            const string localAuthority = "LA0001";
            const string delLocPC       = "testPostcode";
            const string conRefNum      = "tt_1234";
            const string learnAimRef    = "ZESF0001";
            const int    testFunding    = 70; // TypeOfFunding.EuropeanSocialFund

            var learnStart      = DateTime.Parse(startDate);
            var terminationDate = string.IsNullOrEmpty(termination) ? (DateTime?)null : DateTime.Parse(termination);
            var mockDelivery    = new Mock <ILearningDelivery>();

            mockDelivery
            .SetupGet(x => x.FundModel)
            .Returns(testFunding);
            mockDelivery
            .SetupGet(x => x.LearnAimRef)
            .Returns(learnAimRef);
            mockDelivery
            .SetupGet(x => x.CompStatus)
            .Returns(2);     // has completed
            mockDelivery
            .SetupGet(x => x.ConRefNumber)
            .Returns(conRefNum);
            mockDelivery
            .SetupGet(x => x.DelLocPostCode)
            .Returns(delLocPC);
            mockDelivery
            .SetupGet(y => y.LearnStartDate)
            .Returns(learnStart);

            var toDate = string.IsNullOrWhiteSpace(to)
                ? (DateTime?)null
                : DateTime.Parse(to);

            var postcode = new Mock <IONSPostcode>();

            postcode
            .SetupGet(x => x.LocalAuthority)
            .Returns(localAuthority);
            postcode
            .SetupGet(x => x.EffectiveFrom)
            .Returns(DateTime.Parse(from));
            postcode
            .SetupGet(x => x.EffectiveTo)
            .Returns(toDate);
            postcode
            .SetupGet(x => x.Termination)
            .Returns(terminationDate);

            var postcodes = new IONSPostcode[] { postcode.Object };

            var authority = new Mock <IEsfEligibilityRuleLocalAuthority>();

            authority
            .SetupGet(x => x.Code)
            .Returns(localAuthority);

            var authorities = new IEsfEligibilityRuleLocalAuthority[] { authority.Object };
            var deliveries  = new ILearningDelivery[] { mockDelivery.Object };

            var mockLearner = new Mock <ILearner>();

            mockLearner
            .SetupGet(x => x.LearnRefNumber)
            .Returns(learnRefNumber);
            mockLearner
            .SetupGet(x => x.LearningDeliveries)
            .Returns(deliveries);

            var handler = new Mock <IValidationErrorHandler>(MockBehavior.Strict);

            var common = new Mock <IProvideRuleCommonOperations>(MockBehavior.Strict);

            common
            .Setup(x => x.HasQualifyingStart(mockDelivery.Object, DelLocPostCode_17Rule.FirstViableDate, null))
            .Returns(true);

            var fcsData = new Mock <IFCSDataService>(MockBehavior.Strict);

            fcsData
            .Setup(x => x.GetEligibilityRuleLocalAuthoritiesFor(conRefNum))
            .Returns(authorities);

            var postcodesds = new Mock <IPostcodesDataService>(MockBehavior.Strict);

            postcodesds
            .Setup(x => x.GetONSPostcodes(delLocPC))
            .Returns(postcodes);

            var sut = new DelLocPostCode_17Rule(handler.Object, common.Object, fcsData.Object, postcodesds.Object);

            // act
            sut.Validate(mockLearner.Object);

            // assert
            handler.VerifyAll();
            common.VerifyAll();
            fcsData.VerifyAll();
            postcodesds.VerifyAll();
        }