public async Task ThenItShouldGetReferencedEntitiesFromRepository(AggregateEntityReference reference) { _registryProviderMock.Setup(r => r.SearchLearningProvidersAsync(It.IsAny <SearchRequest>(), It.IsAny <CancellationToken>())) .ReturnsAsync(new SearchResultSet { Results = new[] { new SearchResult { Entities = reference.AdapterRecordReferences, }, } }); var context = BuildResolveFieldContext(); await _resolver.ResolveAsync(context); _entityRepositoryMock.Verify(er => er.LoadLearningProvidersAsync( It.Is <LoadLearningProvidersRequest>(r => r.EntityName == "LearningProvider" && r.EntityReferences != null && r.EntityReferences.Length == 1 && r.EntityReferences[0].AdapterRecordReferences.Length == reference.AdapterRecordReferences.Length), context.CancellationToken), Times.Once); }
public async Task ThenItShouldUseRequestedPointIntimeWhenGettingReferencedEntities( AggregateEntityReference reference, DateTime pointInTime) { _registryProviderMock.Setup(r => r.SearchLearningProvidersAsync(It.IsAny <SearchRequest>(), It.IsAny <CancellationToken>())) .ReturnsAsync(new SearchResultSet { Results = new[] { new SearchResult { Entities = reference.AdapterRecordReferences, }, } }); var context = BuildResolveFieldContext(pointInTime: pointInTime); await _resolver.ResolveAsync(context); _entityRepositoryMock.Verify(er => er.LoadLearningProvidersAsync( It.Is <LoadLearningProvidersRequest>(r => r.PointInTime == pointInTime), context.CancellationToken), Times.Once); }
public async Task ThenItShouldAlwaysUseUrnAndUkprnInFieldsWhenGettingReferencedEntities( AggregateEntityReference reference) { _registryProviderMock.Setup(r => r.SearchLearningProvidersAsync(It.IsAny <SearchRequest>(), It.IsAny <CancellationToken>())) .ReturnsAsync(new SearchResultSet { Results = new[] { new SearchResult { Entities = reference.AdapterRecordReferences, }, } }); var context = BuildResolveFieldContext(fields: new[] { "name" }); await _resolver.ResolveAsync(context); _entityRepositoryMock.Verify(er => er.LoadLearningProvidersAsync( It.Is <LoadLearningProvidersRequest>(r => r.Fields != null && r.Fields.Length == 3 && r.Fields.Contains("urn") && r.Fields.Contains("ukprn") && r.Fields.Contains("name")), context.CancellationToken), Times.Once); }
private async Task <LearningProvider> LoadAsync( AggregateEntityReference reference, Dictionary <string, object> arguments, string[] fields, CancellationToken cancellationToken) { var request = new LoadLearningProvidersRequest { EntityReferences = new[] { reference }, Fields = fields, Live = _executionContextManager.GraphExecutionContext.QueryLive, PointInTime = arguments.GetPointInTimeArgument(), }; var loadResult = await _entityRepository.LoadLearningProvidersAsync(request, cancellationToken); return(loadResult.SquashedEntityResults.Select(x => x.SquashedEntity).SingleOrDefault()); }