Example #1
0
        public void InvalidItemRaisesValidationMessage(string aimReference, string startDate)
        {
            // arrange
            const string LearnRefNumber = "123456789X";

            var mockDelivery = new Mock <ILearningDelivery>();

            mockDelivery
            .SetupGet(y => y.LearnAimRef)
            .Returns(aimReference);
            mockDelivery
            .SetupGet(x => x.LearnStartDate)
            .Returns(DateTime.Parse(startDate));

            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 == WorkPlaceStartDate_01Rule.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 == WorkPlaceStartDate_01Rule.MessagePropertyName),
                       Moq.It.IsAny <ILearningDelivery>()))
            .Returns(new Mock <IErrorMessageParameter>().Object);

            var sut = new WorkPlaceStartDate_01Rule(mockHandler.Object);

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

            // assert
            mockHandler.VerifyAll();
        }
Example #2
0
        public void InvalidItemRaisesValidationMessage(string aimReference, string startDate)
        {
            const string LearnRefNumber = "123456789X";

            var mockDelivery = new Mock <ILearningDelivery>();

            mockDelivery
            .SetupGet(y => y.LearnAimRef)
            .Returns(aimReference);
            mockDelivery
            .SetupGet(x => x.LearnStartDate)
            .Returns(DateTime.Parse(startDate));
            mockDelivery
            .SetupGet(x => x.AimSeqNumber)
            .Returns(0);

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

            mockHandler
            .Setup(x => x.Handle("WorkPlaceStartDate_01", LearnRefNumber, 0, Moq.It.IsAny <IEnumerable <IErrorMessageParameter> >()));
            mockHandler
            .Setup(x => x.BuildErrorMessageParameter("LearnAimRef", aimReference))
            .Returns(new Mock <IErrorMessageParameter>().Object);

            var sut = new WorkPlaceStartDate_01Rule(mockHandler.Object);

            sut.Validate(mockLearner.Object);

            mockHandler.VerifyAll();
        }
Example #3
0
        public void ValidItemDoesNotRaiseAValidationMessage(string aimReference, string startDate)
        {
            // arrange
            const string LearnRefNumber = "123456789X";

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

            workplacements.Add(new Mock <ILearningDeliveryWorkPlacement>().Object);

            var mockDelivery = new Mock <ILearningDelivery>();

            mockDelivery
            .SetupGet(y => y.LearningDeliveryWorkPlacements)
            .Returns(workplacements.AsSafeReadOnlyList());
            mockDelivery
            .SetupGet(y => y.LearnAimRef)
            .Returns(aimReference);
            mockDelivery
            .SetupGet(x => x.LearnStartDate)
            .Returns(DateTime.Parse(startDate));

            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 WorkPlaceStartDate_01Rule(mockHandler.Object);

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

            // assert
            mockHandler.VerifyAll();
        }
Example #4
0
        public void ValidItemDoesNotRaiseAValidationMessage(string aimReference, string startDate)
        {
            const string LearnRefNumber = "123456789X";

            var workplacements = new List <ILearningDeliveryWorkPlacement>
            {
                new Mock <ILearningDeliveryWorkPlacement>().Object
            };

            var mockDelivery = new Mock <ILearningDelivery>();

            mockDelivery
            .SetupGet(y => y.LearningDeliveryWorkPlacements)
            .Returns(workplacements);
            mockDelivery
            .SetupGet(y => y.LearnAimRef)
            .Returns(aimReference);
            mockDelivery
            .SetupGet(x => x.LearnStartDate)
            .Returns(DateTime.Parse(startDate));

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

            var sut = new WorkPlaceStartDate_01Rule(mockHandler.Object);

            sut.Validate(mockLearner.Object);

            mockHandler.VerifyAll();
        }