public void Setup() { _handler = new CreateApprenticeshipCommandHandler(Mock.Of <IEmployerCommitmentApi>()); _validCommand = new CreateApprenticeshipCommand { AccountId = 123, Apprenticeship = new Apprenticeship() }; }
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" }; }
public async Task SetUp() { _fixture = new Fixture().Customize(new AutoMoqCustomization()); _employerInformation = _fixture.Create <EmployerInformation>(); _expectedRefNumber = _fixture.Create <int>(); _expectedParameters = _fixture.Freeze <CreateApprenticeshipParameters>(); _validRequest = _fixture.Create <CreateApprenticeshipRequest>(); _mockValidator = _fixture.Freeze <Mock <IValidator <CreateApprenticeshipRequest> > >(composer => composer.Do(mock => mock .Setup(validator => validator.ValidateAsync(It.IsAny <CreateApprenticeshipRequest>(), It.IsAny <CancellationToken>())) .ReturnsAsync(new ValidationResult()))); _mockVacancyOwnerService = _fixture.Freeze <Mock <IVacancyOwnerService> >(composer => composer.Do(mock => mock .Setup(svc => svc.GetEmployersInformationAsync(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>())) .ReturnsAsync(_employerInformation))); _mockMapper = _fixture.Freeze <Mock <ICreateApprenticeshipParametersMapper> >(composer => composer.Do(mock => mock .Setup(mapper => mapper.MapFromRequest(It.IsAny <CreateApprenticeshipRequest>(), It.IsAny <EmployerInformation>())) .Returns(_expectedParameters))); _mockService = _fixture.Freeze <Mock <ICreateApprenticeshipService> >(composer => composer.Do(mock => mock .Setup(repository => repository.CreateApprenticeshipAsync(It.IsAny <CreateApprenticeshipParameters>())) .ReturnsAsync(_expectedRefNumber))); _trainingDetails = new List <TrainingDetail>() { new TrainingDetail() { TrainingCode = _validRequest.TrainingCode, Level = 1 } }; _mockTrainingDetailService = _fixture.Freeze <Mock <ITrainingDetailService> >(composer => composer.Do(mock => { mock .Setup(svc => svc.GetAllFrameworkDetailsAsync()) .ReturnsAsync(_trainingDetails); mock .Setup(svc => svc.GetAllStandardDetailsAsync()) .ReturnsAsync(_trainingDetails); })); _handler = _fixture.Create <CreateApprenticeshipCommandHandler>(); _createApprenticeshipResponse = await _handler.Handle(_validRequest); }
public void Setup() { _commitmentApi = new Mock <IEmployerCommitmentApi>(); _handler = new CreateApprenticeshipCommandHandler(_commitmentApi.Object); _validCommand = new CreateApprenticeshipCommand { AccountId = 123, Apprenticeship = new Apprenticeship { CommitmentId = 5634 }, UserId = "ABC123", UserDisplayName = "Bob", UserEmailAddress = "*****@*****.**" }; }