コード例 #1
0
        public void ShouldThrowValidationErrorAfterR14Close(AcademicYearValidationResult academicYearValidationResult,
                                                            bool expectedPassValidation)
        {
            TestApprenticeship.StartDate     = new DateTime(2017, 3, 1);                         //early last academic year
            ExampleValidRequest.DateOfChange = new DateTime(2017, 5, 1);                         //last academic year
            MockCurrentDateTime.Setup(x => x.Now).Returns(new DateTime(2017, 10, 19, 18, 0, 1)); //after cut-off

            MockAcademicYearValidator.Setup(x => x.Validate(It.IsAny <DateTime>()))
            .Returns(academicYearValidationResult);

            Func <Task> act = async() => await Handler.Handle(ExampleValidRequest);

            if (expectedPassValidation)
            {
                act.ShouldNotThrow <ValidationException>();
            }
            else
            {
                act.ShouldThrow <ValidationException>()
                .WithMessage("Invalid Date of Change. Date cannot be before the academic year start date.");
            }
        }
コード例 #2
0
        public void OfApprovedApprenticeshipThenIsEndDateLockedForUpdateShouldBeSetCorrectly(bool expected, bool unchanged,
                                                                                             bool dataLockSuccess, bool isStartDateInFuture, bool isAfterLastAcademicYearFundingPeriod, AcademicYearValidationResult academicYearValidationResult)
        {
            AcademicYearValidator.Setup(m => m.IsAfterLastAcademicYearFundingPeriod).Returns(isAfterLastAcademicYearFundingPeriod);
            AcademicYearValidator.Setup(m => m.Validate(It.IsAny <DateTime>())).Returns(academicYearValidationResult);

            var apprenticeship = new Apprenticeship
            {
                PaymentStatus         = PaymentStatus.Active,
                HasHadDataLockSuccess = dataLockSuccess,
                StartDate             = _now.AddMonths(isStartDateInFuture ? 1 : -1)
            };

            var commitment = new CommitmentView {
                AgreementStatus = AgreementStatus.BothAgreed
            };

            var viewModel = Sut.MapToApprenticeshipViewModel(apprenticeship, commitment);

            Assert.AreEqual(expected, viewModel.IsEndDateLockedForUpdate);
            if (unchanged)
            {
                Assert.AreEqual(viewModel.IsLockedForUpdate, viewModel.IsEndDateLockedForUpdate);
            }
        }
        public void ThenAcademicYearValidationShouldReturnExpectedResult(DateTime currentDate, DateTime startDate, AcademicYearValidationResult expectedResult)
        {
            //Arrange
            var yearStartDate     = new DateTime(2016, 8, 1);
            var fundingPeriodDate = new DateTime(2017, 10, 19);

            _mockCurrentDateTime.Setup(x => x.Now).Returns(currentDate);
            _academicYear = new Infrastructure.Services.AcademicYearDateProvider(_mockCurrentDateTime.Object);

            _academicYearValidator = new AcademicYearValidator(_mockCurrentDateTime.Object, _academicYear);
            //Act
            var result = _academicYearValidator.Validate(startDate);

            //Assert
            Assert.AreEqual(expectedResult, result);
        }