public void ValidItemDoesNotRaiseValidationMessage(string monitorValue, int empStatus)
        {
            // arrange
            const string LearnRefNumber = "123456789X";

            var monitor = new Mock <IEmploymentStatusMonitoring>();

            monitor
            .SetupGet(y => y.ESMType)
            .Returns(monitorValue.Substring(0, 3));
            monitor
            .SetupGet(y => y.ESMCode)
            .Returns(int.Parse(monitorValue.Substring(3)));

            var monitorings = Collection.Empty <IEmploymentStatusMonitoring>();

            monitorings.Add(monitor.Object);

            var status = new Mock <ILearnerEmploymentStatus>();

            status
            .SetupGet(x => x.EmpStat)
            .Returns(empStatus);
            status
            .SetupGet(x => x.EmploymentStatusMonitorings)
            .Returns(monitorings.AsSafeReadOnlyList());

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

            statii.Add(status.Object);

            var mockLearner = new Mock <ILearner>();

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

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

            var sut = new ESMType_07Rule(handler.Object);

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

            // assert
            handler.VerifyAll();
        }
Esempio n. 2
0
        public void InvalidItemRaisesValidationMessage(string monitorValue, int empStatus)
        {
            const string LearnRefNumber = "123456789X";

            var monitor = new Mock <IEmploymentStatusMonitoring>();

            monitor
            .SetupGet(y => y.ESMType)
            .Returns(monitorValue.Substring(0, 3));
            monitor
            .SetupGet(y => y.ESMCode)
            .Returns(int.Parse(monitorValue.Substring(3)));

            var monitorings = new List <IEmploymentStatusMonitoring>();

            monitorings.Add(monitor.Object);

            var status = new Mock <ILearnerEmploymentStatus>();

            status
            .SetupGet(x => x.EmpStat)
            .Returns(empStatus);
            status
            .SetupGet(x => x.EmploymentStatusMonitorings)
            .Returns(monitorings);

            var statii = new List <ILearnerEmploymentStatus>();

            statii.Add(status.Object);

            var mockLearner = new Mock <ILearner>();

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

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

            handler
            .Setup(x => x.Handle(
                       Moq.It.Is <string>(y => y == ESMType_07Rule.Name),
                       Moq.It.Is <string>(y => y == LearnRefNumber),
                       null,
                       Moq.It.IsAny <IEnumerable <IErrorMessageParameter> >()));
            handler
            .Setup(x => x.BuildErrorMessageParameter(
                       Moq.It.Is <string>(y => y == ESMType_07Rule.MessagePropertyName),
                       Monitoring.EmploymentStatus.Types.SelfEmploymentIndicator))
            .Returns(new Mock <IErrorMessageParameter>().Object);
            handler
            .Setup(x => x.BuildErrorMessageParameter(
                       Moq.It.Is <string>(y => y == PropertyNameConstants.EmpStat),
                       empStatus))
            .Returns(new Mock <IErrorMessageParameter>().Object);

            var sut = new ESMType_07Rule(handler.Object);

            sut.Validate(mockLearner.Object);

            handler.VerifyAll();
        }