public CreateCohortHandlerFixture() { _autoFixture = new Fixture(); _request = _autoFixture.Create <CreateCohortRequest>(); _requestClone = TestHelper.Clone(_request); _draftResponse = _autoFixture.Build <DraftApprenticeshipDto>().Create(); var getDraftApprenticeshipsResponse = new GetDraftApprenticeshipsResponse { DraftApprenticeships = new List <DraftApprenticeshipDto> { _draftResponse } }; var getDraftApprenticeshipResponse = _autoFixture.Build <GetDraftApprenticeshipResponse>() .With(c => c.HasStandardOptions, true) .Create(); _validationResult = new ValidationResult(); _validator = new Mock <IValidator <CreateCohortRequest> >(); _validator.Setup(x => x.Validate(It.IsAny <CreateCohortRequest>())) .Returns(_validationResult); _apiResponse = _autoFixture.Create <CommitmentsV2.Api.Types.Responses.CreateCohortResponse>(); _apiClient = new Mock <ICommitmentsApiClient>(); _apiClient.Setup(x => x.CreateCohort(It.IsAny <CommitmentsV2.Api.Types.Requests.CreateCohortRequest>(), It.IsAny <CancellationToken>())) .ReturnsAsync(_apiResponse); _apiClient.Setup(x => x.GetDraftApprenticeships(_apiResponse.CohortId, It.IsAny <CancellationToken>())) .ReturnsAsync(getDraftApprenticeshipsResponse); _apiClient.Setup(x => x.GetDraftApprenticeship(_apiResponse.CohortId, _draftResponse.Id, It.IsAny <CancellationToken>())) .ReturnsAsync(getDraftApprenticeshipResponse); _mapper = new Mock <IMapper <CreateCohortRequest, CommitmentsV2.Api.Types.Requests.CreateCohortRequest> >(); _apiRequest = _autoFixture.Create <CommitmentsV2.Api.Types.Requests.CreateCohortRequest>(); _mapper.Setup(m => m.Map(_requestClone)) .ReturnsAsync(_apiRequest); _handler = new CreateCohortHandler(_validator.Object, _apiClient.Object, _mapper.Object); }
public CreateCohortHandlerFixture() { var autoFixture = new Fixture(); _request = autoFixture.Create <CreateCohortRequest>(); _requestClone = TestHelper.Clone(_request); _validationResult = new ValidationResult(); _validator = new Mock <IValidator <CreateCohortRequest> >(); _validator.Setup(x => x.Validate(It.IsAny <CreateCohortRequest>())) .Returns(_validationResult); _apiResponse = autoFixture.Create <CommitmentsV2.Api.Types.Responses.CreateCohortResponse>(); _apiClient = new Mock <ICommitmentsApiClient>(); _apiClient.Setup(x => x.CreateCohort(It.IsAny <CommitmentsV2.Api.Types.Requests.CreateCohortRequest>(), It.IsAny <CancellationToken>())) .ReturnsAsync(_apiResponse); _mapper = new Mock <IMapper <CreateCohortRequest, CommitmentsV2.Api.Types.Requests.CreateCohortRequest> >(); _apiRequest = autoFixture.Create <CommitmentsV2.Api.Types.Requests.CreateCohortRequest>(); _mapper.Setup(m => m.Map(_requestClone)) .ReturnsAsync(_apiRequest); _handler = new CreateCohortHandler(_validator.Object, _apiClient.Object, _mapper.Object); }