public void ValidItemDoesNotRaiseValidationMessage()
        {
            // arrange
            const string LearnRefNumber = "123456789X";
            const int    AimSeqNumber   = 1;

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

            mockDelivery
            .SetupGet(x => x.LearnStartDate)
            .Returns(DateTime.Today);
            mockDelivery
            .SetupGet(x => x.AimType)
            .Returns(TypeOfAim.ProgrammeAim);
            mockDelivery
            .SetupGet(x => x.ProgTypeNullable)
            .Returns(TypeOfLearningProgramme.Traineeship);
            mockDelivery
            .SetupGet(x => x.AimSeqNumber)
            .Returns(AimSeqNumber);
            deliveries.Add(mockDelivery.Object);

            var statii = Collection.Empty <ILearnerEmploymentStatus>();

            var mockStatus = new Mock <ILearnerEmploymentStatus>();

            mockStatus
            .SetupGet(y => y.DateEmpStatApp)
            .Returns(DateTime.Today.AddDays(-1));
            mockStatus
            .SetupGet(y => y.EmpStat)
            .Returns(TypeOfEmploymentStatus.InPaidEmployment);
            statii.Add(mockStatus.Object);

            var mockLearner = new Mock <ILearner>();

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

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

            var sut = new EmpStat_17Rule(handler.Object);

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

            // assert
            handler.VerifyAll();
        }
Пример #2
0
        public void InvalidItemRaisesValidationMessage()
        {
            const string LearnRefNumber = "123456789X";
            const int    AimSeqNumber   = 1;

            var deliveries   = new List <ILearningDelivery>();
            var mockDelivery = new Mock <ILearningDelivery>();

            mockDelivery
            .SetupGet(x => x.LearnStartDate)
            .Returns(DateTime.Today);
            mockDelivery
            .SetupGet(x => x.AimType)
            .Returns(AimTypes.ProgrammeAim);
            mockDelivery
            .SetupGet(x => x.ProgTypeNullable)
            .Returns(ProgTypes.Traineeship);
            mockDelivery
            .SetupGet(x => x.AimSeqNumber)
            .Returns(AimSeqNumber);
            deliveries.Add(mockDelivery.Object);

            var mockEmpStat = new Mock <ILearnerEmploymentStatus>();

            mockEmpStat
            .SetupGet(x => x.EmpStat)
            .Returns(EmploymentStatusEmpStats.NotKnownProvided);

            var statii = new List <ILearnerEmploymentStatus>
            {
                mockEmpStat.Object
            };

            var mockLearner = new Mock <ILearner>();

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

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

            handler
            .Setup(x => x.Handle(
                       Moq.It.Is <string>(y => y == EmpStat_17Rule.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 == EmpStat_17Rule.MessagePropertyName),
                       EmploymentStatusEmpStats.NotKnownProvided))
            .Returns(new Mock <IErrorMessageParameter>().Object);
            handler
            .Setup(x => x.BuildErrorMessageParameter(
                       Moq.It.Is <string>(y => y == PropertyNameConstants.LearnStartDate),
                       DateTime.Today))
            .Returns(new Mock <IErrorMessageParameter>().Object);

            var sut = new EmpStat_17Rule(handler.Object);

            sut.Validate(mockLearner.Object);

            handler.VerifyAll();
        }