public async Task GivenUnauthorizedUser_WhenValidatingSearchParam_ThenExceptionThrown()
        {
            var authorizationService = Substitute.For <IAuthorizationService <DataActions> >();

            authorizationService.CheckAccess(DataActions.Reindex, Arg.Any <CancellationToken>()).Returns(DataActions.Write);
            var validator = new SearchParameterValidator(() => _fhirOperationDataStore.CreateMockScope(), authorizationService, _searchParameterDefinitionManager);

            await Assert.ThrowsAsync <UnauthorizedFhirActionException>(() => validator.ValidateSearchParamterInput(new SearchParameter(), "POST", CancellationToken.None));
        }
        public async Task GivenARunningReinxedJob_WhenValidatingSearchParam_ThenExceptionThrown()
        {
            var fhirOperationDataStore = Substitute.For <IFhirOperationDataStore>();

            fhirOperationDataStore.CheckActiveReindexJobsAsync(Arg.Any <CancellationToken>()).Returns((true, "id"));

            var validator = new SearchParameterValidator(() => fhirOperationDataStore.CreateMockScope(), _authorizationService, _searchParameterDefinitionManager);

            await Assert.ThrowsAsync <JobConflictException>(() => validator.ValidateSearchParamterInput(new SearchParameter(), "POST", CancellationToken.None));
        }
 public async Task GivenValidSearchParam_WhenValidatingSearchParam_ThenNoExceptionThrown(SearchParameter searchParam, string method)
 {
     var validator = new SearchParameterValidator(() => _fhirOperationDataStore.CreateMockScope(), _authorizationService, _searchParameterDefinitionManager);
     await validator.ValidateSearchParamterInput(searchParam, method, CancellationToken.None);
 }