Exemple #1
0
        public void GetONSPostcodeMeetsExpectation(string candidate)
        {
            // arrange
            var delivery = new Mock <ILearningDelivery>();

            delivery
            .SetupGet(x => x.DelLocPostCode)
            .Returns(candidate);

            var handler   = new Mock <IValidationErrorHandler>(MockBehavior.Strict);
            var common    = new Mock <IProvideRuleCommonOperations>(MockBehavior.Strict);
            var fcsData   = new Mock <IFCSDataService>(MockBehavior.Strict);
            var postcodes = new Mock <IPostcodesDataService>(MockBehavior.Strict);

            postcodes
            .Setup(x => x.GetONSPostcodes(candidate))
            .Returns(new[] { new Mock <IONSPostcode>().Object });

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

            // act
            var result = sut.GetONSPostcodes(delivery.Object);

            // assert
            handler.VerifyAll();
            common.VerifyAll();
            fcsData.VerifyAll();
            postcodes.VerifyAll();

            Assert.IsAssignableFrom <IONSPostcode[]>(result);
        }
Exemple #2
0
        public void GetEligibilityItemMeetsExpectation(string candidate)
        {
            // arrange
            var delivery = new Mock <ILearningDelivery>();

            delivery
            .SetupGet(x => x.ConRefNumber)
            .Returns(candidate);

            var expectation = new[] { new Mock <IEsfEligibilityRuleLocalAuthority>().Object };

            var handler = new Mock <IValidationErrorHandler>(MockBehavior.Strict);
            var common  = new Mock <IProvideRuleCommonOperations>(MockBehavior.Strict);
            var fcsData = new Mock <IFCSDataService>(MockBehavior.Strict);

            fcsData
            .Setup(x => x.GetEligibilityRuleLocalAuthoritiesFor(candidate))
            .Returns(expectation);

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

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

            // act
            var result = sut.GetEligibilityItemsFor(delivery.Object);

            // assert
            handler.VerifyAll();
            common.VerifyAll();
            fcsData.VerifyAll();
            postcodes.VerifyAll();

            Assert.IsAssignableFrom <IReadOnlyCollection <IEsfEligibilityRuleLocalAuthority> >(result);
            Assert.Equal(expectation, result);
        }
Exemple #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();
        }