コード例 #1
0
        public void ValidItemDoesNotRaiseAValidationMessage(int typeofFunding, int typeOfAim, string famType, int?priorAdjustment)
        {
            // arrange
            const string LearnRefNumber = "123456789X";

            var mockFam = new Mock <ILearningDeliveryFAM>();

            mockFam
            .SetupGet(y => y.LearnDelFAMType)
            .Returns(famType);

            var fams = Collection.Empty <ILearningDeliveryFAM>();

            fams.Add(mockFam.Object);

            var mockDelivery = new Mock <ILearningDelivery>();

            mockDelivery
            .SetupGet(y => y.FundModel)
            .Returns(typeofFunding);
            mockDelivery
            .SetupGet(y => y.AimType)
            .Returns(typeOfAim);
            mockDelivery
            .SetupGet(y => y.PriorLearnFundAdjNullable)
            .Returns(priorAdjustment);
            mockDelivery
            .SetupGet(x => x.LearningDeliveryFAMs)
            .Returns(fams.AsSafeReadOnlyList());

            var deliveries = Collection.Empty <ILearningDelivery>();

            deliveries.Add(mockDelivery.Object);

            var mockLearner = new Mock <ILearner>();

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

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

            var sut = new PriorLearnFundAdj_02Rule(handler.Object);

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

            // assert
            handler.VerifyAll();
        }
コード例 #2
0
        public void InvalidItemRaisesValidationMessage(int typeofFunding, int typeOfAim, string famType, int?priorAdjustment, int aimSeqNumber)
        {
            // arrange
            const string LearnRefNumber = "123456789X";

            var mockFam = new Mock <ILearningDeliveryFAM>(MockBehavior.Strict);

            mockFam
            .SetupGet(y => y.LearnDelFAMType)
            .Returns(famType);

            var fams = Collection.Empty <ILearningDeliveryFAM>();

            fams.Add(mockFam.Object);

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

            mockDelivery
            .SetupGet(y => y.AimSeqNumber)
            .Returns(aimSeqNumber);
            mockDelivery
            .SetupGet(y => y.FundModel)
            .Returns(typeofFunding);
            mockDelivery
            .SetupGet(y => y.FundModel)
            .Returns(typeofFunding);
            mockDelivery
            .SetupGet(y => y.AimType)
            .Returns(typeOfAim);
            mockDelivery
            .SetupGet(y => y.PriorLearnFundAdjNullable)
            .Returns(priorAdjustment);
            mockDelivery
            .SetupGet(x => x.LearningDeliveryFAMs)
            .Returns(fams.AsSafeReadOnlyList());

            var deliveries = Collection.Empty <ILearningDelivery>();

            deliveries.Add(mockDelivery.Object);

            var mockLearner = new Mock <ILearner>();

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

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

            handler.Setup(x => x.Handle(
                              Moq.It.Is <string>(y => y == PriorLearnFundAdj_02Rule.Name),
                              Moq.It.Is <string>(y => y == LearnRefNumber),
                              aimSeqNumber,
                              Moq.It.IsAny <IEnumerable <IErrorMessageParameter> >()));
            handler
            .Setup(x => x.BuildErrorMessageParameter(
                       Moq.It.Is <string>(y => y == PriorLearnFundAdj_02Rule.MessagePropertyName),
                       Moq.It.IsAny <ILearningDelivery>()))
            .Returns(new Mock <IErrorMessageParameter>().Object);

            var sut = new PriorLearnFundAdj_02Rule(handler.Object);

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

            // assert
            handler.VerifyAll();
            mockFam.VerifyAll();
            mockDelivery.VerifyAll();
        }