Exemple #1
0
        public void ValidItemDoesNotRaiseAValidationMessage()
        {
            // arrange
            const string LearnRefNumber = "123456789X";

            var mockItem = new Mock <ILearningDeliveryWorkPlacement>();

            mockItem
            .SetupGet(y => y.WorkPlaceEmpIdNullable)
            .Returns(WorkPlaceEmpId_04Rule.TemporaryEmpID);
            mockItem
            .SetupGet(y => y.WorkPlaceStartDate)
            .Returns(DateTime.Parse("2018-06-15"));

            var placements = Collection.Empty <ILearningDeliveryWorkPlacement>();

            placements.Add(mockItem.Object);

            var mockDelivery = new Mock <ILearningDelivery>();

            mockDelivery
            .SetupGet(y => y.ProgTypeNullable)
            .Returns(TypeOfLearningProgramme.Traineeship);
            mockDelivery
            .SetupGet(y => y.LearningDeliveryWorkPlacements)
            .Returns(placements.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 service = new Mock <IFileDataService>(MockBehavior.Strict);

            service
            .Setup(xc => xc.FilePreparationDate())
            .Returns(DateTime.Parse("2018-08-14"));

            var sut = new WorkPlaceEmpId_04Rule(handler.Object, service.Object);

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

            // assert
            handler.VerifyAll();
            service.VerifyAll();
        }
Exemple #2
0
        public void HasExceedRegistrationPeriodMeetsExpectation(string startDate, string fileDate, bool expectation)
        {
            var mockItem = new Mock <ILearningDeliveryWorkPlacement>();

            mockItem
            .SetupGet(y => y.WorkPlaceStartDate)
            .Returns(DateTime.Parse(startDate));

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

            service
            .Setup(xc => xc.FilePreparationDate())
            .Returns(DateTime.Parse(fileDate));

            var sut = new WorkPlaceEmpId_04Rule(handler.Object, service.Object);

            var result = sut.HasExceedRegistrationPeriod(mockItem.Object);

            Assert.Equal(expectation, result);
        }
Exemple #3
0
        public void InvalidItemRaisesValidationMessage()
        {
            const string LearnRefNumber = "123456789X";

            var mockItem = new Mock <ILearningDeliveryWorkPlacement>();

            mockItem
            .SetupGet(y => y.WorkPlaceEmpIdNullable)
            .Returns(WorkPlaceEmpId_04Rule.TemporaryEmpID);
            mockItem
            .SetupGet(y => y.WorkPlaceStartDate)
            .Returns(DateTime.Parse("2018-05-14"));

            var placements = new List <ILearningDeliveryWorkPlacement>
            {
                mockItem.Object
            };

            var mockDelivery = new Mock <ILearningDelivery>();

            mockDelivery
            .SetupGet(y => y.ProgTypeNullable)
            .Returns(ProgTypes.Traineeship);
            mockDelivery
            .SetupGet(y => y.LearningDeliveryWorkPlacements)
            .Returns(placements);

            var deliveries = new List <ILearningDelivery>
            {
                mockDelivery.Object
            };

            var mockLearner = new Mock <ILearner>();

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

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

            handler.Setup(x => x.Handle(
                              Moq.It.Is <string>(y => y == RuleNameConstants.WorkPlaceEmpId_04),
                              Moq.It.Is <string>(y => y == LearnRefNumber),
                              0,
                              Moq.It.IsAny <IEnumerable <IErrorMessageParameter> >()));
            handler
            .Setup(x => x.BuildErrorMessageParameter(
                       Moq.It.Is <string>(y => y == PropertyNameConstants.WorkPlaceEmpId),
                       WorkPlaceEmpId_04Rule.TemporaryEmpID))
            .Returns(new Mock <IErrorMessageParameter>().Object);

            var service = new Mock <IFileDataService>(MockBehavior.Strict);

            service
            .Setup(xc => xc.FilePreparationDate())
            .Returns(DateTime.Parse("2018-08-14"));

            var sut = new WorkPlaceEmpId_04Rule(handler.Object, service.Object);

            sut.Validate(mockLearner.Object);

            handler.VerifyAll();
            service.VerifyAll();
        }