public void ValidItemDoesNotRaiseValidationMessage(int funding, int?progType)
        {
            // arrange
            const string LearnRefNumber = "123456789X";
            const string learnAimRef    = "salddfkjeifdnase";

            var mockDelivery = new Mock <ILearningDelivery>();

            mockDelivery
            .SetupGet(y => y.LearnAimRef)
            .Returns(learnAimRef);
            mockDelivery
            .SetupGet(y => y.LearnStartDate)
            .Returns(DateTime.Parse("2017-08-01"));
            mockDelivery
            .SetupGet(y => y.FundModel)
            .Returns(funding);
            mockDelivery
            .SetupGet(y => y.ProgTypeNullable)
            .Returns(progType);

            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 validity = new Mock <ILARSValidity>();

            validity
            .SetupGet(x => x.ValidityCategory)
            .Returns(TypeOfLARSValidity.Any);
            validity
            .SetupGet(x => x.StartDate)
            .Returns(DateTime.Parse("2016-04-03"));

            var larsValidities = Collection.Empty <ILARSValidity>();

            larsValidities.Add(validity.Object);

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

            service
            .Setup(x => x.GetValiditiesFor(learnAimRef))
            .Returns(larsValidities.AsSafeReadOnlyList());

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

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

            // assert
            handler.VerifyAll();
            service.VerifyAll();
        }
        public void InvalidItemRaisesValidationMessage(int funding, int?progType)
        {
            // arrange
            const string LearnRefNumber = "123456789X";
            const string learnAimRef    = "salddfkjeifdnase";

            var mockDelivery = new Mock <ILearningDelivery>();

            mockDelivery
            .SetupGet(y => y.LearnAimRef)
            .Returns(learnAimRef);
            mockDelivery
            .SetupGet(y => y.LearnStartDate)
            .Returns(DateTime.Parse("2017-08-01"));
            mockDelivery
            .SetupGet(y => y.FundModel)
            .Returns(funding);
            mockDelivery
            .SetupGet(y => y.ProgTypeNullable)
            .Returns(progType);

            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);

            handler
            .Setup(x => x.Handle(
                       Moq.It.Is <string>(y => y == LearnAimRef_37Rule.Name),
                       Moq.It.Is <string>(y => y == LearnRefNumber),
                       0,
                       Moq.It.IsAny <IEnumerable <IErrorMessageParameter> >()));
            handler
            .Setup(x => x.BuildErrorMessageParameter(
                       Moq.It.Is <string>(y => y == LearnAimRef_37Rule.MessagePropertyName),
                       Moq.It.IsAny <ILearningDelivery>()))
            .Returns(new Mock <IErrorMessageParameter>().Object);

            var larsValidities = Collection.Empty <ILARSValidity>();

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

            service
            .Setup(x => x.GetValiditiesFor(learnAimRef))
            .Returns(larsValidities.AsSafeReadOnlyList());

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

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

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