protected CachingGraphQLResolver CreateSut(params ISchemaEntity[] schemas) { var cache = new BackgroundCache(new MemoryCache(Options.Create(new MemoryCacheOptions()))); var appProvider = A.Fake <IAppProvider>(); A.CallTo(() => appProvider.GetSchemasAsync(TestApp.Default.Id, default)) .Returns(schemas.ToList()); var services = new ServiceCollection() .AddMemoryCache() .AddTransient <GraphQLExecutionContext>() .Configure <AssetOptions>(x => { x.CanCache = true; }) .Configure <ContentOptions>(x => { x.CanCache = true; }) .AddSingleton <IDocumentExecutionListener, DataLoaderDocumentListener>() .AddSingleton <IDataLoaderContextAccessor, DataLoaderContextAccessor>() .AddTransient <IAssetCache, AssetCache>() .AddTransient <IContentCache, ContentCache>() .AddSingleton <IUrlGenerator, FakeUrlGenerator>() .AddSingleton(A.Fake <ILoggerFactory>()) .AddSingleton(appProvider) .AddSingleton(assetQuery) .AddSingleton(commandBus) .AddSingleton(contentQuery) .AddSingleton(userResolver) .AddSingleton <InstantGraphType>() .AddSingleton <JsonGraphType>() .AddSingleton <JsonNoopGraphType>() .BuildServiceProvider(); var schemasHash = A.Fake <ISchemasHash>(); return(new CachingGraphQLResolver(cache, schemasHash, services, Options.Create(new GraphQLOptions()))); }
private CachingGraphQLService CreateSut() { var cache = new BackgroundCache(new MemoryCache(Options.Create(new MemoryCacheOptions()))); var appProvider = A.Fake <IAppProvider>(); A.CallTo(() => appProvider.GetSchemasAsync(appId.Id)) .Returns(new List <ISchemaEntity> { schema, schemaRef1, schemaRef2, schemaInvalidName }); var dataLoaderContext = (IDataLoaderContextAccessor) new DataLoaderContextAccessor(); var dataLoaderListener = new DataLoaderDocumentListener(dataLoaderContext); var services = new ServiceCollection() .AddMemoryCache() .AddTransient <GraphQLExecutionContext>() .AddSingleton(A.Fake <ISemanticLog>()) .AddSingleton(appProvider) .AddSingleton(assetQuery) .AddSingleton(commandBus) .AddSingleton(contentQuery) .AddSingleton(dataLoaderContext) .AddSingleton(dataLoaderListener) .AddSingleton(userResolver) .AddSingleton <InstantGraphType>() .AddSingleton <JsonGraphType>() .AddSingleton <JsonNoopGraphType>() .AddSingleton <SharedTypes>() .AddSingleton <IUrlGenerator, FakeUrlGenerator>() .BuildServiceProvider(); var schemasHash = A.Fake <ISchemasHash>(); return(new CachingGraphQLService(cache, schemasHash, services, Options.Create(new GraphQLOptions()))); }