Пример #1
0
        public void ValidItemDoesNotRaiseValidationMessage(int funding, int?progType)
        {
            // arrange
            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.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_38Rule(handler.Object, service.Object);

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

            // assert
            handler.VerifyAll();
            service.VerifyAll();
        }
Пример #2
0
        [InlineData("2013-07-16", "2015-05-09", "2013-07-15", TypeOfLARSValidity.Any, false)]                 // out of date, correct category
        public void HasValidLearningAimMeetsExpectation(string candidate, string startDate, string endDate, string category, bool expectation)
        {
            // arrange
            const string learnAimRef = "salddfkjeifdnase";

            var mockDelivery = new Mock <ILearningDelivery>();

            mockDelivery
            .SetupGet(y => y.LearnAimRef)
            .Returns(learnAimRef);
            mockDelivery
            .SetupGet(y => y.LearnStartDate)
            .Returns(DateTime.Parse(candidate));

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

            var mockValidity = new Mock <ILARSValidity>();

            mockValidity
            .SetupGet(x => x.ValidityCategory)
            .Returns(category);
            mockValidity
            .SetupGet(x => x.StartDate)
            .Returns(DateTime.Parse(startDate));
            mockValidity
            .SetupGet(x => x.EndDate)
            .Returns(DateTime.Parse(endDate));

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

            larsValidities.Add(mockValidity.Object);

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

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

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

            // act
            var result = sut.HasValidLearningAim(mockDelivery.Object);

            // assert
            Assert.Equal(expectation, result);
            handler.VerifyAll();
            service.VerifyAll();
        }
Пример #3
0
        public void ValidItemThroughExclusionDoesNotRaiseValidationMessage(string famType)
        {
            // arrange
            var mockFAM = new Mock <ILearningDeliveryFAM>();

            mockFAM
            .SetupGet(y => y.LearnDelFAMType)
            .Returns(famType);

            var fams = Collection.Empty <ILearningDeliveryFAM>();

            fams.Add(mockFAM.Object);

            var mockDelivery = new Mock <ILearningDelivery>();

            mockDelivery
            .SetupGet(y => y.LearningDeliveryFAMs)
            .Returns(fams.AsSafeReadOnlyList());

            var deliveries = Collection.Empty <ILearningDelivery>();

            deliveries.Add(mockDelivery.Object);

            var mockLearner = new Mock <ILearner>();

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

            var handler = new Mock <IValidationErrorHandler>(MockBehavior.Strict);
            var service = new Mock <ILARSDataService>(MockBehavior.Strict);
            var sut     = new LearnAimRef_38Rule(handler.Object, service.Object);

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

            // assert
            handler.VerifyAll();
            service.VerifyAll();
        }
Пример #4
0
        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_38Rule.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_38Rule.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_38Rule(handler.Object, service.Object);

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

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