public void GetTotalTNPPriceForMeetsExpectation(int expectation)
        {
            var deliveries = new ILearningDelivery[] { };

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

            derivedData
            .Setup(x => x.GetTotalTNPPriceFor(deliveries))
            .Returns(expectation);

            var sut = new R72Rule(handler.Object, derivedData.Object);

            var result = sut.GetTotalTNPPriceFor(deliveries);

            Assert.Equal(expectation, result);

            handler.VerifyAll();
            derivedData.VerifyAll();
        }
        public void HasQualifyingModelMeetsExpectation(int fundModel, bool expectation)
        {
            var delivery = new Mock <ILearningDelivery>();

            delivery
            .SetupGet(y => y.FundModel)
            .Returns(fundModel);

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

            var sut = new R72Rule(handler.Object, derivedData.Object);

            var result = sut.HasQualifyingModel(delivery.Object);

            Assert.Equal(expectation, result);

            handler.VerifyAll();
            derivedData.VerifyAll();
        }
        public void IsTNPMoreThanContributionCapForMeetsExpectation(int candidate, bool expectation)
        {
            var deliveries = new ILearningDelivery[] { };

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

            derivedData
            .Setup(x => x.IsTNPMoreThanContributionCapFor(candidate, deliveries))
            .Returns(expectation);

            var sut = new R72Rule(handler.Object, derivedData.Object);

            var result = sut.IsTNPMoreThanContributionCapFor(candidate, deliveries);

            Assert.Equal(expectation, result);

            handler.VerifyAll();
            derivedData.VerifyAll();
        }
        public void ValidItemDoesNotRaiseValidationMessage(int tnpTotal, params int[] recordPairs)
        {
            const string LearnRefNumber = "123456789X";
            const int    testStdCode    = 234;

            var records = new List <IAppFinRecord>();

            for (var i = 0; i < recordPairs.Length; i += 2)
            {
                var temp = new Mock <IAppFinRecord>();
                temp.SetupGet(x => x.AFinType).Returns("PMR");
                temp.SetupGet(x => x.AFinCode).Returns(recordPairs[i]);
                temp.SetupGet(x => x.AFinAmount).Returns(recordPairs[i + 1]);

                records.Add(temp.Object);
            }

            var delivery = new Mock <ILearningDelivery>(MockBehavior.Strict);

            delivery
            .SetupGet(x => x.StdCodeNullable)
            .Returns(testStdCode);
            delivery
            .SetupGet(y => y.FundModel)
            .Returns(81);
            delivery
            .SetupGet(x => x.AppFinRecords)
            .Returns(records);

            var deliveries = new ILearningDelivery[] { delivery.Object };

            var mockLearner = new Mock <ILearner>();

            mockLearner
            .SetupGet(x => x.LearnRefNumber)
            .Returns(LearnRefNumber);
            mockLearner
            .SetupGet(x => x.LearningDeliveries)
            .Returns(deliveries);
            delivery
            .SetupGet(x => x.AimType)
            .Returns(1);
            delivery
            .SetupGet(x => x.ProgTypeNullable)
            .Returns(25);

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

            var derivedData = new Mock <IDerivedData_17Rule>(MockBehavior.Strict);

            derivedData
            .Setup(x => x.IsTNPMoreThanContributionCapFor(testStdCode, Moq.It.IsAny <IReadOnlyCollection <ILearningDelivery> >()))
            .Returns(false);
            derivedData
            .Setup(x => x.GetTotalTNPPriceFor(deliveries))
            .Returns(tnpTotal);

            var sut = new R72Rule(handler.Object, derivedData.Object);

            sut.Validate(mockLearner.Object);

            handler.VerifyAll();
            derivedData.VerifyAll();
        }