public void ThenProviderIdIsValidated(long providerId, bool expectedValid) { var request = new SelectEmployerRequest { ProviderId = providerId }; AssertValidationResult(x => x.ProviderId, request, expectedValid); }
public SelectEmployerViewModelMapperFixture() { _providerId = 123; _accountLegalEntityId = 457; _apprenticeshipId = 1; _request = new SelectEmployerRequest { ProviderId = _providerId, ApprenticeshipId = _apprenticeshipId }; _apiResponse = new GetAccountProviderLegalEntitiesWithPermissionResponse { AccountProviderLegalEntities = new List <AccountProviderLegalEntityDto> { new AccountProviderLegalEntityDto { AccountId = 123, AccountLegalEntityPublicHashedId = "DSFF23", AccountLegalEntityName = "TestAccountLegalEntityName", AccountPublicHashedId = "DFKFK66", AccountName = "TestAccountName", AccountLegalEntityId = 456, AccountProviderId = 234 }, new AccountProviderLegalEntityDto { AccountId = 124, AccountLegalEntityPublicHashedId = "DSFF24", AccountLegalEntityName = "TestAccountLegalEntityName2", AccountPublicHashedId = "DFKFK67", AccountName = "TestAccountNam2", AccountLegalEntityId = _accountLegalEntityId, AccountProviderId = 235 } } }; GetApprenticeshipApiResponse = new CommitmentsV2.Api.Types.Responses.GetApprenticeshipResponse { AccountLegalEntityId = _accountLegalEntityId, EmployerName = "TestName" }; _providerRelationshipsApiClientMock = new Mock <IProviderRelationshipsApiClient>(); _providerRelationshipsApiClientMock .Setup(x => x.GetAccountProviderLegalEntitiesWithPermission( It.IsAny <GetAccountProviderLegalEntitiesWithPermissionRequest>(), CancellationToken.None)) .ReturnsAsync(_apiResponse); _commitmentApiClientMock = new Mock <ICommitmentsApiClient>(); _commitmentApiClientMock.Setup(x => x.GetApprenticeship(_apprenticeshipId, It.IsAny <CancellationToken>())) .ReturnsAsync(GetApprenticeshipApiResponse); _sut = new SelectEmployerViewModelMapper(_providerRelationshipsApiClientMock.Object, _commitmentApiClientMock.Object); }
public SelectEmployerFixture() { _request = new SelectEmployerRequest { ProviderId = 1, ApprenticeshipId = 1 }; _modelMapperMock = new Mock <IModelMapper>(); _viewModel = new SelectEmployerViewModel { AccountProviderLegalEntities = new List <AccountProviderLegalEntityViewModel>(), }; _modelMapperMock .Setup(x => x.Map <SelectEmployerViewModel>(_request)) .ReturnsAsync(_viewModel); Sut = new ApprenticeController(_modelMapperMock.Object, Mock.Of <ICookieStorageService <IndexRequest> >(), Mock.Of <ICommitmentsApiClient>()); }
public SelectEmployerFixture() { _request = new SelectEmployerRequest { ProviderId = _providerId }; _modelMapperMock = new Mock <IModelMapper>(); _viewModel = new SelectEmployerViewModel { AccountProviderLegalEntities = new List <AccountProviderLegalEntityViewModel>(), BackLink = "Test.com" }; _providerId = 123; _modelMapperMock .Setup(x => x.Map <SelectEmployerViewModel>(_request)) .ReturnsAsync(_viewModel); Sut = new CohortController(Mock.Of <IMediator>(), _modelMapperMock.Object, Mock.Of <ILinkGenerator>(), Mock.Of <ICommitmentsApiClient>(), Mock.Of <IFeatureTogglesService <ProviderFeatureToggle> >(), Mock.Of <IEncodingService>()); }
public async Task <IActionResult> SelectEmployer(SelectEmployerRequest request) { var model = await _modelMapper.Map <SelectEmployerViewModel>(request); return(View(model)); }
private void AssertValidationResult <T>(Expression <Func <SelectEmployerRequest, T> > property, SelectEmployerRequest instance, bool expectedValid) { var validator = new SelectEmployerRequestValidator(); if (expectedValid) { validator.ShouldNotHaveValidationErrorFor(property, instance); } else { validator.ShouldHaveValidationErrorFor(property, instance); } }
internal SelectEmployerViewModelMapperFixture WithRequest(SelectEmployerRequest selectEmployerRequest) { _request = selectEmployerRequest; return(this); }