public void SetUp()
        {
            _mockApprenticeshipEvents     = new Mock <IApprenticeshipEvents>();
            _mockCommitmentRespository    = new Mock <ICommitmentRepository>();
            _mockApprenticeshipRepository = new Mock <IApprenticeshipRepository>();
            _mockHistoryRepository        = new Mock <IHistoryRepository>();
            _mockUlnValidator             = new Mock <IUlnValidator>();
            _mockAcademicYearValidator    = new Mock <IAcademicYearValidator>();

            var validator = new CreateApprenticeshipValidator(new ApprenticeshipValidator(new StubCurrentDateTime(), _mockUlnValidator.Object, _mockAcademicYearValidator.Object));

            _handler = new CreateApprenticeshipCommandHandler(
                _mockCommitmentRespository.Object,
                _mockApprenticeshipRepository.Object,
                validator,
                _mockApprenticeshipEvents.Object,
                Mock.Of <ICommitmentsLogger>(),
                _mockHistoryRepository.Object);

            var fixture = new Fixture();
            var populatedApprenticeship = fixture.Build <Apprenticeship>()
                                          .With(x => x.ULN, "1234567890")
                                          .With(x => x.ULN, ApprenticeshipTestDataHelper.CreateValidULN())
                                          .With(x => x.NINumber, ApprenticeshipTestDataHelper.CreateValidNino())
                                          .With(x => x.FirstName, "First name")
                                          .With(x => x.FirstName, "Last name")
                                          .With(x => x.ProviderRef, "Provider ref")
                                          .With(x => x.EmployerRef, null)
                                          .With(x => x.StartDate, DateTime.Now.AddYears(5))
                                          .With(x => x.EndDate, DateTime.Now.AddYears(7))
                                          .With(x => x.DateOfBirth, DateTime.Now.AddYears(-16))
                                          .With(x => x.TrainingCode, string.Empty)
                                          .With(x => x.TrainingName, string.Empty)
                                          .Create();

            _mockApprenticeshipRepository.Setup(m => m.GetApprenticeship(It.IsAny <long>()))
            .ReturnsAsync(new Domain.Entities.Apprenticeship {
                Id = expectedApprenticeshipId, ProviderId = _providerId, EmployerAccountId = _employerAccountId
            });

            _exampleValidRequest = new CreateApprenticeshipCommand
            {
                Caller = new Caller
                {
                    CallerType = CallerType.Provider,
                    Id         = 111L
                },
                CommitmentId   = 123L,
                Apprenticeship = populatedApprenticeship,
                UserId         = "ABBA123"
            };
        }
Beispiel #2
0
        public void Setup()
        {
            _validator = new CreateApprenticeshipValidator(new ApprenticeshipValidator(new StubCurrentDateTime(), Mock.Of <IUlnValidator>(), Mock.Of <IAcademicYearValidator>()));
            var exampleValidApprenticeship = new Domain.Entities.Apprenticeship
            {
                FirstName   = "Bob", LastName = "Smith", NINumber = ApprenticeshipTestDataHelper.CreateValidNino(),
                ULN         = ApprenticeshipTestDataHelper.CreateValidULN(),
                ProviderRef = "Provider ref", EmployerRef = null,
                StartDate   = DateTime.Now.AddYears(5),
                EndDate     = DateTime.Now.AddYears(7)
            };

            _exampleCommand = new CreateApprenticeshipCommand
            {
                Caller = new Caller
                {
                    CallerType = CallerType.Provider,
                    Id         = 1
                },
                CommitmentId   = 123L,
                Apprenticeship = exampleValidApprenticeship
            };
        }