public async Task UploadBatchDelegatesToPublishingEndPoint() { Mock <IFormFile> file = new Mock <IFormFile>(); byte[] contents = { 3, 63, 8, 100 }; MemoryStream ms = new MemoryStream(); StreamWriter writer = new StreamWriter(ms); writer.Write(File.Create("blah blah")); await writer.FlushAsync(); ms.Position = 0; file.Setup(_ => _.CopyToAsync(It.IsAny <Stream>(), It.IsAny <CancellationToken>())) .Returns((Stream stream, CancellationToken token) => ms.CopyToAsync(stream)) .Verifiable(); file.SetupGet(x => x.Length).Returns(contents.Length); BatchUploadResponse expectedResponse = new BatchUploadResponse { BatchId = Guid.NewGuid().ToString(), Url = "http:whatever" }; _publishingApiClient .UploadBatch(Arg.Any <BatchUploadRequest>()) .Returns(new ApiResponse <BatchUploadResponse>(HttpStatusCode.OK, expectedResponse)); OkObjectResult result = await _publishController.UploadBatch(file.Object) as OkObjectResult; result.Should().NotBeNull(); result? .Value .Should() .BeSameAs(expectedResponse); }
public async Task GetPublishedProviderErrors_ReturnsErrorSummaries_WhenUnderlyingAPIReturnsErrorSummaries() { string errorSummary = "Error"; IEnumerable <string> errorSummaries = new List <string> { errorSummary }; _publishingApiClient .GetPublishedProviderErrors(ValidSpecificationId) .Returns(new ApiResponse <IEnumerable <string> >(HttpStatusCode.OK, errorSummaries)); IActionResult result = await _publishController.GetSpecProviderErrors(ValidSpecificationId); result.Should().BeOfType <OkObjectResult>(); OkObjectResult okObjectResult = result as OkObjectResult; okObjectResult.Should().NotBeNull(); okObjectResult.Value.Should().NotBeNull(); okObjectResult.Value.Should().BeOfType <List <string> >(); IEnumerable <string> actualErrorSummaries = okObjectResult.Value as IEnumerable <string>; actualErrorSummaries.Count().Should().Be(1); string actualErrorSummary = actualErrorSummaries.FirstOrDefault(); actualErrorSummary.Should().Be(errorSummary); }
public async Task ReturnsChangesWhenGetCurrentProfileConfig() { string fundingLineName = "FundingLineName"; IEnumerable <FundingLineProfile> actualFundingLineChanges = new List <FundingLineProfile> { new FundingLineProfile { FundingLineName = fundingLineName } }; GivenGetCurrentProfileConfig( HttpStatusCode.OK, actualFundingLineChanges); IActionResult actualResult = await WhenGetCurrentProfileConfig(); actualResult.Should().BeOfType <OkObjectResult>(); OkObjectResult okObjectResult = actualResult as OkObjectResult; okObjectResult.Should().NotBeNull(); okObjectResult.Value.Should().NotBeNull(); okObjectResult.Value.Should().BeOfType <List <FundingLineProfile> >(); IEnumerable <FundingLineProfile> fundingLineProfiles = okObjectResult.Value as IEnumerable <FundingLineProfile>; fundingLineProfiles.Count().Should().Be(1); FundingLineProfile fundingLineProfile = fundingLineProfiles.FirstOrDefault(); fundingLineProfile.Should().NotBeNull(); fundingLineProfile.FundingLineName.Should().Be(fundingLineName); }
public void GetUserTaskBoards_RequestingTaskBoardsForExistingUser_ReturnsOK() { // ARRANGE List <TaskBoardPublic> taskBoards = new List <TaskBoardPublic> { new TaskBoardPublic() { ID = 1, Name = Guid.NewGuid().ToString(), UserID = 1 }, new TaskBoardPublic() { ID = 2, Name = Guid.NewGuid().ToString(), UserID = 1 }, new TaskBoardPublic() { ID = 3, Name = Guid.NewGuid().ToString(), UserID = 2 } }; ITaskBoardRepository taskBoardRepository = new MemoryTaskBoardRepository(taskBoards); TaskBoardController controller = new TaskBoardController(taskBoardRepository); // ACT OkObjectResult result = controller.GetUserTaskBoards(1) as OkObjectResult; // ASSERT result.Should().NotBeNull(); result.StatusCode.Should().Be(200); }
public void ValueAs_Null_ShouldFail() { ActionResult result = new OkObjectResult(null); string failureMessage = FailureMessageHelper.ExpectedContextTypeXButFoundNull( "OkObjectResult.Value", typeof(object)); Action a = () => result.Should().BeOkObjectResult().ValueAs <object>(); a.Should().Throw <Exception>() .WithMessage(failureMessage); }
public async Task ReturnsChangeExistsWhenPreviousProfileExists() { GivenPreviousProfileExistsForSpecificationForProviderForFundingLine( HttpStatusCode.OK, true); IActionResult actualResult = await WhenPreviousProfileExistsForSpecificationForProviderForFundingLine(); actualResult.Should().BeOfType <OkObjectResult>(); OkObjectResult okObjectResult = actualResult as OkObjectResult; okObjectResult.Should().NotBeNull(); okObjectResult.Value.Should().NotBeNull(); okObjectResult.Value.Should().Be(true); }
public async Task ReturnsPublishedProviderDetailsWhenPreviousProfileExists() { GivenGetFundingLinePublishedProviderDetailsForFundingLine( HttpStatusCode.OK, new FundingLineProfile()); GivenFundingConfiguration( HttpStatusCode.OK, new FundingConfiguration()); IActionResult actualResult = await WhenGetFundingLinePublishedProviderDetails(); actualResult.Should().BeOfType <OkObjectResult>(); OkObjectResult okObjectResult = actualResult as OkObjectResult; okObjectResult.Should().NotBeNull(); okObjectResult.Value.Should().NotBeNull(); }
public async Task ReturnsOkObjectResultWithNoFundingStreamIds_GivenNoSpecificationWithSelectedForFunding() { ISpecificationsRepository specificationsRepository = CreateSpecificationsRepository(); specificationsRepository.GetSpecificationsByQuery(Arg.Any <Expression <Func <DocumentEntity <Specification>, bool> > >()) .Returns(new[] { _specNotSelectedForFunding }); SpecificationsService service = CreateService(specificationsRepository: specificationsRepository); OkObjectResult fundingStreamIdResult = await service.GetFundingStreamIdsForSelectedFundingSpecifications() as OkObjectResult; IEnumerable <string> fundingStreamIds = fundingStreamIdResult.Value as IEnumerable <string>; fundingStreamIdResult.Should().BeOfType <OkObjectResult>(); fundingStreamIds.Count().Should().Be(0); }
public async Task ReturnsOkObjectResultWithNoFundingStreamIds_DistinctFundingStreamIdsForSpecifications() { ISpecificationsRepository specificationsRepository = CreateSpecificationsRepository(); specificationsRepository.GetDistinctFundingStreamsForSpecifications() .Returns(new List <string>() { }); SpecificationsService service = CreateService(specificationsRepository: specificationsRepository); OkObjectResult fundingStreamIdResult = await service.GetDistinctFundingStreamsForSpecifications() as OkObjectResult; IEnumerable <string> fundingStreamIds = fundingStreamIdResult.Value as IEnumerable <string>; fundingStreamIdResult.Should().BeOfType <OkObjectResult>(); fundingStreamIds.Count().Should().Be(0); }
public async Task ReturnsPublishedFundingTemplatesForGivenFundingStreamAndPeriod() { DateTime expectedPublishDate = new RandomDateTime(); IEnumerable <PolicyApiClientModel.PublishedFundingTemplate> publishedFundingTemplates = new List <PolicyApiClientModel.PublishedFundingTemplate> { new PolicyApiClientModel.PublishedFundingTemplate() { AuthorName = "AuthName", AuthorId = "AuthId", PublishDate = expectedPublishDate, PublishNote = "SomeComments", SchemaVersion = "1.2", TemplateVersion = "2.3" } }; GivenApiPublishedFundingTemplates(_fundingStreamId, _fundingPeriodId, publishedFundingTemplates); OkObjectResult result = await WhenGetPublishedFundingTemplates(_fundingStreamId, _fundingPeriodId) as OkObjectResult; result .Should() .NotBeNull(); PublishedFundingTemplate template = result.Value.As <IEnumerable <PublishedFundingTemplate> >().FirstOrDefault(); template .Should() .NotBeNull(); template .Should() .BeEquivalentTo(new PublishedFundingTemplate { AuthorName = "AuthName", PublishNote = "SomeComments", MinorVersion = "3", MajorVersion = "2", PublishDate = expectedPublishDate, SchemaVersion = "1.2" }); }
public async Task ApproveAllCalculations_GivenApproveAllCalculationsReturnsJob_ReturnsOK() { //Arrange string specificationId = "abc123"; string jobId = "job123"; Job job = new Job { Id = jobId }; ICalculationsApiClient calcsClient = Substitute.For <ICalculationsApiClient>(); calcsClient .QueueApproveAllSpecificationCalculations(Arg.Is(specificationId)) .Returns(new ApiResponse <Job>(HttpStatusCode.OK, job)); IMapper mapper = MappingHelper.CreateFrontEndMapper(); IAuthorizationHelper authorizationHelper = Substitute.For <IAuthorizationHelper>(); authorizationHelper.DoesUserHavePermission(Arg.Any <ClaimsPrincipal>(), Arg.Is(specificationId), Arg.Is(SpecificationActionTypes.CanApproveAllCalculations)) .Returns(true); CalculationController controller = CreateCalculationController(calcsClient, mapper, authorizationHelper, resultsApiClient); // Act IActionResult result = await controller.ApproveAllCalculations(specificationId); // Assert result.Should().BeOfType <OkObjectResult>(); OkObjectResult okObjectResult = result as OkObjectResult; okObjectResult.Should().NotBeNull(); okObjectResult.Value.Should().NotBeNull(); okObjectResult.Value.Should().BeOfType <Job>(); Job actualJob = okObjectResult.Value as Job; actualJob.Id.Should().Be(jobId); }
public async Task ReturnsOkObjectResultWithNoFundingPeriod_GivenFundingStreamIdHasNoAssociationToSpecificationWithFundingPeriod() { specificationsRepository.GetSpecificationsByQuery(Arg.Any <Expression <Func <DocumentEntity <Specification>, bool> > >()) .Returns(new[] { _specWithNoFundingStream, }); SpecificationsService service = CreateService( specificationsRepository: specificationsRepository, policiesApiClient: policiesApiClient, mapper: mapper); OkObjectResult fundingPeriodsResult = await service.GetFundingPeriodsByFundingStreamIdsForSelectedSpecifications(FundingStreamIdForExpectedFundingPeriod) as OkObjectResult; IEnumerable <Reference> fundingPeriod = fundingPeriodsResult.Value as IEnumerable <Reference>; fundingPeriodsResult.Should().BeOfType <OkObjectResult>(); fundingPeriod.Count().Should().Be(0); }
public void GetTaskBoard_OnValidRequest_ReturnOK() { // ARRANGE ITaskBoardRepository taskBoardRepository = new MemoryTaskBoardRepository(); taskBoardRepository.CreateTaskBoard(new TaskBoardPublic() { ID = 1 }); TaskBoardController controller = new TaskBoardController(taskBoardRepository); controller.ProblemDetailsFactory = new MockProblemDetailsFactory(); // ACT OkObjectResult result = controller.GetTaskBoard(1) as OkObjectResult; // ASSERT result.Should().NotBeNull(); result.StatusCode.Should().Be(200); }
public async Task ReturnsChangesWhenPreviousProfileChanges() { string fundingLineName = "FundingLineName"; IEnumerable <FundingLineChange> actualFundingLineChanges = new List <FundingLineChange> { new FundingLineChange { FundingLineName = fundingLineName } }; GivenProviderExists(); GivenSpecificationExists(); GivenGetPreviousProfilesForSpecificationForProviderForFundingLine( HttpStatusCode.OK, actualFundingLineChanges); IActionResult actualResult = await WhenGetPreviousProfilesForSpecificationForProviderForFundingLine(); actualResult.Should().BeOfType <OkObjectResult>(); OkObjectResult okObjectResult = actualResult as OkObjectResult; okObjectResult.Should().NotBeNull(); okObjectResult.Value.Should().NotBeNull(); okObjectResult.Value.Should().BeOfType <FundingLineChangesViewModel>(); FundingLineChangesViewModel viewModel = okObjectResult.Value as FundingLineChangesViewModel; viewModel.ProviderName.Should().Be("Provider name"); viewModel.SpecificationName.Should().Be("Spec name"); viewModel.FundingPeriodName.Should().Be("Funding period name"); IEnumerable <FundingLineChange> fundingLineChanges = viewModel.FundingLineChanges; fundingLineChanges.Count().Should().Be(1); FundingLineChange fundingLineChange = fundingLineChanges.FirstOrDefault(); fundingLineChange.Should().NotBeNull(); fundingLineChange.FundingLineName.Should().Be(fundingLineName); }
public void SetResultFromDistributionCache_IfValidRequestIsCached(string httpMethod, string idempotencyKey) { // Arrange string requestBodyString = @"{""message"":""This is a dummy message""}"; int expectedResponseHeadersCount = 2; var requestHeaders = new HeaderDictionary(); requestHeaders.Add("Content-Type", "application/json"); requestHeaders.Add(_headerKeyName, idempotencyKey); // The expected result var expectedExecutionResult = new OkObjectResult(new ResponseModelBasic() { Id = 1, CreatedOn = new DateTime(2019, 10, 12, 5, 25, 25) }); var actionContext = ArrangeActionContextMock(httpMethod, requestHeaders, requestBodyString, new HeaderDictionary(), null); var actionExecutingContext = new ActionExecutingContext( actionContext, new List <IFilterMetadata>(), new Dictionary <string, object>(), Mock.Of <Controller>() ); var idempotencyAttributeFilter = new IdempotencyAttributeFilter(_sharedDistributedCache.Cache, _loggerFactory, true, 1, _headerKeyName, _distributedCacheKeysPrefix); // Act idempotencyAttributeFilter.OnActionExecuting(actionExecutingContext); // Assert (result should not be null) Assert.NotNull(actionExecutingContext.Result); // Assert (result should be equal to expected value) expectedExecutionResult.Should().Equals(actionExecutingContext.Result); // Assert (response headers count) Assert.Equal(expectedResponseHeadersCount, actionExecutingContext.HttpContext.Response.Headers.Count); }
public async Task CorrelatesPaymentDatesForFundingStreamWithProfileTotalsToMarkAnyInThePastAsPaid() { DateTimeOffset utcNow = DateTimeOffset.Parse("2020-03-20"); PublishedProviderVersion publishedProviderVersion = NewPublishedProviderVersion(_ => _.WithFundingLines(NewFundingLine( fl => fl.WithFundingLineType(FundingLineType.Payment) .WithDistributionPeriods(NewDistributionPeriod(dp => dp.WithProfilePeriods(NewProfilePeriod(pp => pp.WithTypeValue("January") .WithYear(2020) .WithOccurence(1)), NewProfilePeriod(pp => pp.WithTypeValue("January") .WithYear(2020) .WithOccurence(2)), NewProfilePeriod(pp => pp.WithTypeValue("February") .WithYear(2020) .WithOccurence(1)), NewProfilePeriod(pp => pp.WithTypeValue("February") .WithYear(2020) .WithOccurence(2)), NewProfilePeriod(pp => pp.WithTypeValue("March") .WithYear(2020) .WithOccurence(1)), NewProfilePeriod(pp => pp.WithTypeValue("March") .WithYear(2020) .WithOccurence(2)), NewProfilePeriod(pp => pp.WithTypeValue("April") .WithYear(2020) .WithOccurence(1)), NewProfilePeriod(pp => pp.WithTypeValue("April") .WithYear(2020) .WithOccurence(2)) )))))); FundingStreamPaymentDates paymentDates = NewPaymentDates(_ => _.WithPaymentDates( NewPaymentDate(pd => pd.WithOccurence(1) .WithYear(2020) .WithTypeValue("January") .WithOccurence(1) .WithDate("2020-01-07")), NewPaymentDate(pd => pd.WithOccurence(1) .WithYear(2020) .WithTypeValue("January") .WithOccurence(2) .WithDate("2020-01-21")), NewPaymentDate(pd => pd.WithOccurence(1) .WithYear(2020) .WithTypeValue("February") .WithOccurence(1) .WithDate("2020-02-07")), NewPaymentDate(pd => pd.WithOccurence(1) .WithYear(2020) .WithTypeValue("February") .WithOccurence(2) .WithDate("2020-02-21")), NewPaymentDate(pd => pd.WithOccurence(1) .WithYear(2020) .WithTypeValue("March") .WithOccurence(1) .WithDate("2020-03-07")), NewPaymentDate(pd => pd.WithOccurence(1) .WithYear(2020) .WithTypeValue("March") .WithOccurence(2) .WithDate("2020-03-21")), NewPaymentDate(pd => pd.WithOccurence(1) .WithYear(2020) .WithTypeValue("April") .WithOccurence(1) .WithDate("2020-04-07")), NewPaymentDate(pd => pd.WithOccurence(1) .WithYear(2020) .WithTypeValue("April") .WithOccurence(2) .WithDate("2020-04-21")) )); string fundingStreamId = NewRandomString(); string fundingPeriodId = NewRandomString(); string providerId = NewRandomString(); GivenTheCurrentDateTime(utcNow); AndTheLatestPublishedProviderVersion(fundingStreamId, fundingPeriodId, providerId, publishedProviderVersion); AndThePaymentDates(fundingStreamId, fundingPeriodId, paymentDates); OkObjectResult result = (await WhenTheProfileHistoryIsQueried(fundingStreamId, fundingPeriodId, providerId)) as OkObjectResult; result .Should() .NotBeNull(); ProfileTotal[] expectedProfileTotals = new[] { NewProfileTotal(_ => _.WithYear(2020) .WithTypeValue("January") .WithOccurrence(1) .WithIsPaid(true)), NewProfileTotal(_ => _.WithYear(2020) .WithTypeValue("January") .WithOccurrence(2) .WithIsPaid(true)), NewProfileTotal(_ => _.WithYear(2020) .WithTypeValue("February") .WithOccurrence(1) .WithIsPaid(true)), NewProfileTotal(_ => _.WithYear(2020) .WithTypeValue("February") .WithOccurrence(2) .WithIsPaid(true)), NewProfileTotal(_ => _.WithYear(2020) .WithTypeValue("March") .WithOccurrence(1) .WithIsPaid(true)), NewProfileTotal(_ => _.WithYear(2020) .WithTypeValue("March") .WithOccurrence(2) .WithIsPaid(false)), NewProfileTotal(_ => _.WithYear(2020) .WithTypeValue("April") .WithOccurrence(1) .WithIsPaid(false)), NewProfileTotal(_ => _.WithYear(2020) .WithTypeValue("April") .WithOccurrence(2) .WithIsPaid(false)), }; result .Value .Should() .BeEquivalentTo(expectedProfileTotals, opt => opt.WithoutStrictOrdering()); }
public async Task GetProviderDataForAllReleaseAsCsv_ShouldSaveCsvFileInStorageConstinerAndReturnsBlobUrl() { IEnumerable <string> publishedProviderIds = new[] { NewRandomString(), NewRandomString() }; string fundingPeriodId = NewRandomString(); string fundingStreamId = NewRandomString(); string providerName1 = NewRandomString(); string providerName2 = NewRandomString(); _validator.Validate(Arg.Is(_specificationId)) .Returns(new ValidationResult()); IEnumerable <PublishedProviderFundingCsvData> expectedCsvData = new[] { new PublishedProviderFundingCsvData() { FundingStreamId = fundingStreamId, FundingPeriodId = fundingPeriodId, SpecificationId = _specificationId, ProviderName = providerName1, TotalFunding = 123 }, new PublishedProviderFundingCsvData() { FundingStreamId = fundingStreamId, FundingPeriodId = fundingPeriodId, SpecificationId = _specificationId, ProviderName = providerName2, TotalFunding = 4567 } }; ICloudBlob blob = Substitute.For <ICloudBlob>(); blob.Properties.Returns(new BlobProperties()); blob.Metadata.Returns(new Dictionary <string, string>()); string expectedUrl = "https://blob.test.com/tst"; PublishedProviderStatus[] statuses = new[] { PublishedProviderStatus.Approved }; string blobNamePrefix = $"{fundingStreamId}-{fundingPeriodId}"; GivenTheFundingDataForCsv(expectedCsvData, publishedProviderIds, _specificationId, statuses); GivenBolbReference(blobNamePrefix, blob); GivenBlobUrl(blobNamePrefix, expectedUrl); GivenThePublishedProviderIdsForTheSpecificationId(publishedProviderIds); OkObjectResult result = await WhenTheGetProviderDataForAllReleaseAsCsvExecuted(_specificationId) as OkObjectResult; result .Should() .NotBeNull(); result.Value .Should() .BeOfType <PublishedProviderDataDownload>() .Which .Url .Should() .Be(expectedUrl); await _fundingCsvDataProcessor .Received(1) .GetFundingData( Arg.Is <IEnumerable <string> >(ids => ids.SequenceEqual(publishedProviderIds)), Arg.Is(_specificationId), Arg.Is <PublishedProviderStatus[]>(s => s.SequenceEqual(statuses))); _blobClient .Received(1) .GetBlockBlobReference(Arg.Is <string>(x => x.StartsWith(blobNamePrefix)), Arg.Is(BlobContainerName)); await blob .Received(1) .UploadFromStreamAsync(Arg.Any <Stream>()); _blobClient .Received(1) .GetBlobSasUrl(Arg.Is <string>(x => x.StartsWith(blobNamePrefix)), Arg.Any <DateTimeOffset>(), Arg.Is(SharedAccessBlobPermissions.Read), Arg.Is(BlobContainerName)); }
public async Task DelegatesToSearchRepositoryAndMapsResultsIntoOkObjectResult() { Dictionary <string, string[]> nonFacetFilters = new Dictionary <string, string[]> { { "filter1", new[] { "filter1value1", "filter1value2" } } }; Dictionary <string, string[]> facetFilters = new Dictionary <string, string[]> { { "hasErrors", new[] { "true" } }, { "providerType", new[] { "test", "" } } }; SearchModel searchModel = NewSearchModel(builder => { builder.WithTop(50) .WithPageNumber(1) .WithSearchTerm(NewRandomString()) .WithIncludeFacets(true); foreach (var nonFacetFilter in nonFacetFilters) { builder.AddFilter(nonFacetFilter.Key, nonFacetFilter.Value); } foreach (var facetFilter in facetFilters) { builder.AddFilter(facetFilter.Key, facetFilter.Value); } }); GivenTheSearchModel(searchModel); SearchResults <PublishedProviderIndex> searchIndexResults = NewSearchResults(_ => _.WithResults(NewPublishedProviderIndex(), NewPublishedProviderIndex(), NewPublishedProviderIndex())); AndTheSearchResults(searchModel, searchIndexResults); OkObjectResult result = await WhenTheSearchIsMade() as OkObjectResult; result .Should() .NotBeNull(); PublishedSearchResults publishedSearchResults = result.Value as PublishedSearchResults; publishedSearchResults .Facets .Should() .NotBeNull(); IEnumerable <PublishedSearchResult> results = publishedSearchResults.Results; results .Should() .NotBeNull(); results.Select(_ => _.Id) .Should() .BeEquivalentTo(searchIndexResults.Results.Select(_ => _.Result.Id)); await ThenTheFiltersWasSearched(searchModel, PublishedSearchService.Facets.Length - nonFacetFilters.Count, "(providerType eq 'test' or providerType eq '') and (hasErrors eq true) and (filter1 eq 'filter1value1' or filter1 eq 'filter1value2')"); await ThenTheFiltersWasSearched(searchModel, 1, "(providerType eq 'test' or providerType eq '') and (filter1 eq 'filter1value1' or filter1 eq 'filter1value2')"); await AndTheFilterWasSearched(searchModel, 1, "(hasErrors eq true) and (filter1 eq 'filter1value1' or filter1 eq 'filter1value2')"); }
public async Task GetsPublishedProviderLocalAuthorities() { string fundingStreamId = "fundingStreamId1"; string fundingPeriodId = "fundingPeriodId1"; string searchText = "Der"; string matchingFacetName = "Derby"; string unmatchingFacetName = "Kent"; string matchingTwoWordFacetName = "North Derby"; SearchResults <PublishedProviderIndex> searchResults = new SearchResults <PublishedProviderIndex> { Facets = new List <Facet> { new Facet { Name = "localAuthority", FacetValues = new List <FacetValue> { new FacetValue { Name = matchingFacetName }, new FacetValue { Name = unmatchingFacetName }, new FacetValue { Name = matchingTwoWordFacetName }, } } } }; GivenSearchResultsForLocalAuthority(searchText, searchResults); OkObjectResult result = await WhenSearchLocalAuthorityIsMade(searchText, fundingStreamId, fundingPeriodId) as OkObjectResult; result .Should() .NotBeNull(); await ThenFacetValuesWasSearched(searchText, fundingStreamId, fundingPeriodId); IEnumerable <string> publishedProviderLocalAuthorities = result.Value as IEnumerable <string>; publishedProviderLocalAuthorities .Should() .HaveCount(2); publishedProviderLocalAuthorities .First() .Should() .BeEquivalentTo(matchingFacetName); publishedProviderLocalAuthorities .Last() .Should() .BeEquivalentTo(matchingTwoWordFacetName); }