예제 #1
0
        public void InQualifyingPeriodMeetsExpectation(string candidateCode, string candidate, bool expectation)
        {
            // arrange
            var testdate = DateTime.Parse(candidate);

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

            provider
            .Setup(x => x.IsCurrent(TypeOfLimitedLifeLookup.EmploymentStatusMonitoring, candidateCode, testdate))
            .Returns(expectation);

            var sut = new ESMType_11Rule(handler.Object, provider.Object);

            var mockItem = new Mock <IEmploymentStatusMonitoring>();

            mockItem
            .SetupGet(x => x.ESMType)
            .Returns(candidateCode.Substring(0, 3));
            mockItem
            .SetupGet(x => x.ESMCode)
            .Returns(int.Parse(candidateCode.Substring(3)));

            // act
            var result = sut.InQualifyingPeriod(mockItem.Object, testdate);

            // assert
            Assert.Equal(expectation, result);
        }
        public void ValidItemDoesNotRaiseValidationMessage(string candidateCode, string candidate)
        {
            const string LearnRefNumber = "123456789X";

            var testDate = DateTime.Parse(candidate);

            var mockItem = new Mock <IEmploymentStatusMonitoring>();

            mockItem
            .SetupGet(x => x.ESMType)
            .Returns(candidateCode.Substring(0, 3));
            mockItem
            .SetupGet(x => x.ESMCode)
            .Returns(int.Parse(candidateCode.Substring(3)));

            var monitorings = new List <IEmploymentStatusMonitoring>();

            monitorings.Add(mockItem.Object);

            var status = new Mock <ILearnerEmploymentStatus>();

            status
            .SetupGet(x => x.DateEmpStatApp)
            .Returns(testDate);
            status
            .SetupGet(x => x.EmpStat)
            .Returns(EmploymentStatusEmpStats.NotEmployedSeekingAndAvailable);
            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);

            var provider = new Mock <IProvideLookupDetails>(MockBehavior.Strict);

            provider
            .Setup(x => x.IsCurrent(TypeOfLimitedLifeLookup.ESMType, candidateCode, testDate))
            .Returns(true);

            var sut = new ESMType_11Rule(handler.Object, provider.Object);

            sut.Validate(mockLearner.Object);

            handler.VerifyAll();
        }
예제 #3
0
        public void InvalidItemRaisesValidationMessage(string candidateCode, string candidate)
        {
            // arrange
            const string LearnRefNumber = "123456789X";

            var testDate = DateTime.Parse(candidate);

            var mockItem = new Mock <IEmploymentStatusMonitoring>();

            mockItem
            .SetupGet(x => x.ESMType)
            .Returns(candidateCode.Substring(0, 3));
            mockItem
            .SetupGet(x => x.ESMCode)
            .Returns(int.Parse(candidateCode.Substring(3)));

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

            monitorings.Add(mockItem.Object);

            var status = new Mock <ILearnerEmploymentStatus>();

            status
            .SetupGet(x => x.DateEmpStatApp)
            .Returns(testDate);
            status
            .SetupGet(x => x.EmpStat)
            .Returns(TypeOfEmploymentStatus.NotEmployedSeekingAndAvailable);
            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);

            handler
            .Setup(x => x.Handle(
                       Moq.It.Is <string>(y => y == ESMType_11Rule.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 == "DateEmpStatApp"),
                       testDate))
            .Returns(new Mock <IErrorMessageParameter>().Object);

            // we want it to 'fail'; so we return false
            var provider = new Mock <IProvideLookupDetails>(MockBehavior.Strict);

            provider
            .Setup(x => x.IsCurrent(TypeOfLimitedLifeLookup.EmploymentStatusMonitoring, candidateCode, testDate))
            .Returns(false);

            var sut = new ESMType_11Rule(handler.Object, provider.Object);

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

            // assert
            handler.VerifyAll();
        }