public void ValidItemDoesNotRaiseAValidationMessage(string learnDate, string finDate)
        {
            // arrange
            const string LearnRefNumber = "123456789X";

            var mockFinRec = new Mock <IAppFinRecord>();

            mockFinRec
            .SetupGet(x => x.AFinType)
            .Returns(ApprenticeshipFinancialRecord.Types.TotalNegotiatedPrice);
            mockFinRec
            .SetupGet(x => x.AFinDate)
            .Returns(DateTime.Parse(finDate));

            var records = Collection.Empty <IAppFinRecord>();

            records.Add(mockFinRec.Object);

            var mockDelivery = new Mock <ILearningDelivery>();

            mockDelivery
            .SetupGet(x => x.AimType)
            .Returns(TypeOfAim.ProgrammeAim);
            mockDelivery
            .SetupGet(x => x.FundModel)
            .Returns(TypeOfFunding.ApprenticeshipsFrom1May2017);
            mockDelivery
            .SetupGet(x => x.LearnStartDate)
            .Returns(DateTime.Parse(learnDate));
            mockDelivery
            .SetupGet(x => x.AppFinRecords)
            .Returns(records.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 mockHandler = new Mock <IValidationErrorHandler>(MockBehavior.Strict);

            var sut = new AFinType_13Rule(mockHandler.Object);

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

            // assert
            mockHandler.VerifyAll();
        }
コード例 #2
0
        public void ValidItemDoesNotRaiseAValidationMessage(string learnDate, string finDate, string aFinType)
        {
            const string LearnRefNumber = "123456789X";

            var mockFinRec = new Mock <IAppFinRecord>();

            mockFinRec
            .SetupGet(x => x.AFinType)
            .Returns(aFinType);
            mockFinRec
            .SetupGet(x => x.AFinDate)
            .Returns(DateTime.Parse(finDate));

            var records = new List <IAppFinRecord>();

            records.Add(mockFinRec.Object);

            var mockDelivery = new Mock <ILearningDelivery>();

            mockDelivery
            .SetupGet(x => x.AimType)
            .Returns(AimTypes.ProgrammeAim);
            mockDelivery
            .SetupGet(x => x.FundModel)
            .Returns(FundModels.ApprenticeshipsFrom1May2017);
            mockDelivery
            .SetupGet(x => x.LearnStartDate)
            .Returns(DateTime.Parse(learnDate));
            mockDelivery
            .SetupGet(x => x.AppFinRecords)
            .Returns(records);

            var deliveries = new List <ILearningDelivery>();

            deliveries.Add(mockDelivery.Object);

            var mockLearner = new Mock <ILearner>();

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

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

            var sut = new AFinType_13Rule(mockHandler.Object);

            sut.Validate(mockLearner.Object);

            mockHandler.VerifyAll();
        }
コード例 #3
0
        public void ValidateWithEmptyAppFinRecordsDoesNotRaiseValidationMessage()
        {
            // arrange
            const string LearnRefNumber = "123456789X";

            var mockDelivery = new Mock <ILearningDelivery>();

            mockDelivery
            .SetupGet(x => x.AimType)
            .Returns(TypeOfAim.ProgrammeAim);
            mockDelivery
            .SetupGet(x => x.FundModel)
            .Returns(TypeOfFunding.ApprenticeshipsFrom1May2017);

            mockDelivery
            .SetupGet(x => x.AppFinRecords)
            .Returns(Collection.EmptyAndReadOnly <IAppFinRecord>());

            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 mockHandler = new Mock <IValidationErrorHandler>(MockBehavior.Strict);

            mockHandler.Setup(x => x.Handle(
                                  Moq.It.Is <string>(y => y == AFinType_13Rule.Name),
                                  Moq.It.Is <string>(y => y == LearnRefNumber),
                                  0,
                                  Moq.It.IsAny <IEnumerable <IErrorMessageParameter> >()));
            mockHandler
            .Setup(x => x.BuildErrorMessageParameter(
                       Moq.It.Is <string>(y => y == AFinType_13Rule.MessagePropertyName),
                       Moq.It.Is <object>(y => y == mockDelivery.Object)))
            .Returns(new Mock <IErrorMessageParameter>().Object);

            var sut = new AFinType_13Rule(mockHandler.Object);

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

            // assert
            mockHandler.VerifyAll();
        }
コード例 #4
0
        public void ValidateWithNullAppFinRecordsDoesNotRaiseValidationMessage()
        {
            const string LearnRefNumber = "123456789X";
            const string aFinType       = "TNP";
            var          aFinDate       = string.Empty;
            var          learnStartDate = new DateTime(2018, 8, 1);

            var mockDelivery = new Mock <ILearningDelivery>();

            mockDelivery
            .SetupGet(x => x.LearnStartDate)
            .Returns(learnStartDate);
            mockDelivery
            .SetupGet(x => x.AimType)
            .Returns(AimTypes.ProgrammeAim);
            mockDelivery
            .SetupGet(x => x.FundModel)
            .Returns(FundModels.ApprenticeshipsFrom1May2017);

            var deliveries = new List <ILearningDelivery>();

            deliveries.Add(mockDelivery.Object);

            var mockLearner = new Mock <ILearner>();

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

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

            mockHandler.Setup(x => x.Handle(
                                  Moq.It.Is <string>(y => y == AFinType_13Rule.Name),
                                  Moq.It.Is <string>(y => y == LearnRefNumber),
                                  0,
                                  Moq.It.IsAny <IEnumerable <IErrorMessageParameter> >()));
            mockHandler
            .Setup(x => x.BuildErrorMessageParameter(
                       Moq.It.Is <string>(y => y == PropertyNameConstants.LearnStartDate),
                       Moq.It.Is <DateTime>(y => y == learnStartDate)))
            .Returns(new Mock <IErrorMessageParameter>().Object);
            mockHandler
            .Setup(x => x.BuildErrorMessageParameter(
                       Moq.It.Is <string>(y => y == PropertyNameConstants.AFinType),
                       Moq.It.Is <string>(y => y == aFinType)))
            .Returns(new Mock <IErrorMessageParameter>().Object);
            mockHandler
            .Setup(x => x.BuildErrorMessageParameter(
                       Moq.It.Is <string>(y => y == PropertyNameConstants.AFinDate),
                       Moq.It.Is <string>(y => y == aFinDate)))
            .Returns(new Mock <IErrorMessageParameter>().Object);

            var sut = new AFinType_13Rule(mockHandler.Object);

            sut.Validate(mockLearner.Object);

            mockHandler.VerifyAll();
        }
コード例 #5
0
        public void InvalidItemRaisesValidationMessage(string learnDate, string finDate, string aFinType)
        {
            const string LearnRefNumber = "123456789X";
            var          aFinDate       = string.Empty;
            var          learnStartDate = DateTime.Parse(learnDate);

            var mockFinRec = new Mock <IAppFinRecord>();

            mockFinRec
            .SetupGet(x => x.AFinType)
            .Returns(aFinType);
            mockFinRec
            .SetupGet(x => x.AFinDate)
            .Returns(DateTime.Parse(finDate));

            var records = new List <IAppFinRecord>();

            records.Add(mockFinRec.Object);

            var mockDelivery = new Mock <ILearningDelivery>();

            mockDelivery
            .SetupGet(x => x.AimType)
            .Returns(1);
            mockDelivery
            .SetupGet(x => x.FundModel)
            .Returns(36);
            mockDelivery
            .SetupGet(x => x.LearnStartDate)
            .Returns(learnStartDate);
            mockDelivery
            .SetupGet(x => x.AppFinRecords)
            .Returns(records);

            var deliveries = new List <ILearningDelivery>();

            deliveries.Add(mockDelivery.Object);

            var mockLearner = new Mock <ILearner>();

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

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

            mockHandler.Setup(x => x.Handle(
                                  Moq.It.Is <string>(y => y == AFinType_13Rule.Name),
                                  Moq.It.Is <string>(y => y == LearnRefNumber),
                                  0,
                                  Moq.It.IsAny <IEnumerable <IErrorMessageParameter> >()));
            mockHandler
            .Setup(x => x.BuildErrorMessageParameter(
                       Moq.It.Is <string>(y => y == "LearnStartDate"),
                       Moq.It.Is <DateTime>(y => y == learnStartDate)))
            .Returns(new Mock <IErrorMessageParameter>().Object);
            mockHandler
            .Setup(x => x.BuildErrorMessageParameter(
                       Moq.It.Is <string>(y => y == "AFinType"),
                       Moq.It.Is <string>(y => y == aFinType.ToUpper())))
            .Returns(new Mock <IErrorMessageParameter>().Object);
            mockHandler
            .Setup(x => x.BuildErrorMessageParameter(
                       Moq.It.Is <string>(y => y == "AFinDate"),
                       Moq.It.Is <string>(y => y == aFinDate)))
            .Returns(new Mock <IErrorMessageParameter>().Object);

            var sut = new AFinType_13Rule(mockHandler.Object);

            sut.Validate(mockLearner.Object);

            mockHandler.VerifyAll();
        }
        public void InvalidItemRaisesValidationMessage(string learnDate, string finDate)
        {
            // arrange
            const string LearnRefNumber = "123456789X";
            const string aFinType       = ApprenticeshipFinancialRecord.Types.TotalNegotiatedPrice;
            var          aFinDate       = string.Empty;
            var          learnStartDate = DateTime.Parse(learnDate);

            var mockFinRec = new Mock <IAppFinRecord>();

            mockFinRec
            .SetupGet(x => x.AFinType)
            .Returns(aFinType);
            mockFinRec
            .SetupGet(x => x.AFinDate)
            .Returns(DateTime.Parse(finDate));

            var records = Collection.Empty <IAppFinRecord>();

            records.Add(mockFinRec.Object);

            var mockDelivery = new Mock <ILearningDelivery>();

            mockDelivery
            .SetupGet(x => x.AimType)
            .Returns(TypeOfAim.ProgrammeAim);
            mockDelivery
            .SetupGet(x => x.FundModel)
            .Returns(TypeOfFunding.ApprenticeshipsFrom1May2017);
            mockDelivery
            .SetupGet(x => x.LearnStartDate)
            .Returns(learnStartDate);
            mockDelivery
            .SetupGet(x => x.AppFinRecords)
            .Returns(records.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 mockHandler = new Mock <IValidationErrorHandler>(MockBehavior.Strict);

            mockHandler.Setup(x => x.Handle(
                                  Moq.It.Is <string>(y => y == AFinType_13Rule.Name),
                                  Moq.It.Is <string>(y => y == LearnRefNumber),
                                  0,
                                  Moq.It.IsAny <IEnumerable <IErrorMessageParameter> >()));
            mockHandler
            .Setup(x => x.BuildErrorMessageParameter(
                       Moq.It.Is <string>(y => y == PropertyNameConstants.LearnStartDate),
                       Moq.It.Is <DateTime>(y => y == learnStartDate)))
            .Returns(new Mock <IErrorMessageParameter>().Object);
            mockHandler
            .Setup(x => x.BuildErrorMessageParameter(
                       Moq.It.Is <string>(y => y == PropertyNameConstants.AFinType),
                       Moq.It.Is <string>(y => y == aFinType)))
            .Returns(new Mock <IErrorMessageParameter>().Object);
            mockHandler
            .Setup(x => x.BuildErrorMessageParameter(
                       Moq.It.Is <string>(y => y == PropertyNameConstants.AFinDate),
                       Moq.It.Is <string>(y => y == aFinDate)))
            .Returns(new Mock <IErrorMessageParameter>().Object);

            var sut = new AFinType_13Rule(mockHandler.Object);

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

            // assert
            mockHandler.VerifyAll();
        }