Esempio n. 1
0
        public ResourceDefinitionReadTests(ExampleIntegrationTestContext <TestableStartup <UniverseDbContext>, UniverseDbContext> testContext)
        {
            _testContext = testContext;

            testContext.UseController <StarsController>();
            testContext.UseController <PlanetsController>();
            testContext.UseController <MoonsController>();

            testContext.ConfigureServicesAfterStartup(services =>
            {
                services.AddResourceDefinition <StarDefinition>();
                services.AddResourceDefinition <PlanetDefinition>();
                services.AddResourceDefinition <MoonDefinition>();

                services.AddSingleton <IClientSettingsProvider, TestClientSettingsProvider>();
                services.AddSingleton <ResourceDefinitionHitCounter>();
            });

            var options = (JsonApiOptions)testContext.Factory.Services.GetRequiredService <IJsonApiOptions>();

            options.IncludeTotalResourceCount = true;

            var settingsProvider = (TestClientSettingsProvider)testContext.Factory.Services.GetRequiredService <IClientSettingsProvider>();

            settingsProvider.ResetToDefaults();

            var hitCounter = _testContext.Factory.Services.GetRequiredService <ResourceDefinitionHitCounter>();

            hitCounter.Reset();
        }
Esempio n. 2
0
        public AtomicCreateResourceWithToOneRelationshipTests(
            ExampleIntegrationTestContext <TestableStartup <OperationsDbContext>, OperationsDbContext> testContext)
        {
            _testContext = testContext;

            testContext.ConfigureServicesAfterStartup(services => services.AddControllersFromExampleProject());
        }
        public ExceptionHandlerTests(ExampleIntegrationTestContext <TestableStartup <ErrorDbContext>, ErrorDbContext> testContext)
        {
            _testContext = testContext;

            testContext.UseController <ThrowingArticlesController>();
            testContext.UseController <ConsumerArticlesController>();

            FakeLoggerFactory loggerFactory = null;

            testContext.ConfigureLogging(options =>
            {
                loggerFactory = new FakeLoggerFactory();

                options.ClearProviders();
                options.AddProvider(loggerFactory);
                options.SetMinimumLevel(LogLevel.Warning);
            });

            testContext.ConfigureServicesBeforeStartup(services =>
            {
                if (loggerFactory != null)
                {
                    services.AddSingleton(_ => loggerFactory);
                }
            });

            testContext.ConfigureServicesAfterStartup(services =>
            {
                services.AddResourceService <ConsumerArticleService>();
                services.AddScoped <IExceptionHandler, AlternateExceptionHandler>();
            });
        }
        public ResourceHookTests(ExampleIntegrationTestContext <ResourceHooksStartup <HooksDbContext>, HooksDbContext> testContext)
        {
            _testContext = testContext;

            testContext.UseController <ArticlesController>();
            testContext.UseController <AuthorsController>();
            testContext.UseController <PassportsController>();
            testContext.UseController <PeopleController>();
            testContext.UseController <TodoItemsController>();
            testContext.UseController <UsersController>();

            testContext.ConfigureServicesAfterStartup(services =>
            {
                services.AddScoped <ResourceHooksDefinition <Article>, ArticleHooksDefinition>();
                services.AddScoped <ResourceHooksDefinition <Passport>, PassportHooksDefinition>();
                services.AddScoped <ResourceHooksDefinition <Person>, PersonHooksDefinition>();
                services.AddScoped <ResourceHooksDefinition <Tag>, TagHooksDefinition>();
                services.AddScoped <ResourceHooksDefinition <TodoItem>, TodoItemHooksDefinition>();

                services.AddScoped(typeof(IResourceChangeTracker <>), typeof(NeverSameResourceChangeTracker <>));
            });

            var options = (JsonApiOptions)testContext.Factory.Services.GetRequiredService <IJsonApiOptions>();

            options.DisableTopPagination      = false;
            options.DisableChildrenPagination = false;
        }
Esempio n. 5
0
        public EagerLoadingTests(ExampleIntegrationTestContext <TestableStartup <EagerLoadingDbContext>, EagerLoadingDbContext> testContext)
        {
            _testContext = testContext;

            testContext.ConfigureServicesAfterStartup(services =>
            {
                services.AddResourceRepository <BuildingRepository>();
            });
        }
Esempio n. 6
0
        public ResourceMetaTests(ExampleIntegrationTestContext <TestableStartup <SupportDbContext>, SupportDbContext> testContext)
        {
            _testContext = testContext;

            testContext.ConfigureServicesAfterStartup(services =>
            {
                services.AddScoped <IResourceDefinition <SupportTicket>, SupportTicketDefinition>();
            });
        }
        public SoftDeletionTests(ExampleIntegrationTestContext <TestableStartup <SoftDeletionDbContext>, SoftDeletionDbContext> testContext)
        {
            _testContext = testContext;

            testContext.ConfigureServicesAfterStartup(services =>
            {
                services.AddScoped <IResourceDefinition <Company>, SoftDeletionResourceDefinition <Company> >();
                services.AddScoped <IResourceDefinition <Department>, SoftDeletionResourceDefinition <Department> >();
            });
        }
        public DisableQueryStringTests(ExampleIntegrationTestContext <TestableStartup <RestrictionDbContext>, RestrictionDbContext> testContext)
        {
            _testContext = testContext;

            testContext.ConfigureServicesAfterStartup(services =>
            {
                services.AddScoped <SkipCacheQueryStringParameterReader>();
                services.AddScoped <IQueryStringParameterReader>(sp => sp.GetRequiredService <SkipCacheQueryStringParameterReader>());
            });
        }
Esempio n. 9
0
        public AtomicCreateResourceWithClientGeneratedIdTests(ExampleIntegrationTestContext <TestableStartup <OperationsDbContext>, OperationsDbContext> testContext)
        {
            _testContext = testContext;

            testContext.ConfigureServicesAfterStartup(services => services.AddControllersFromExampleProject());

            var options = (JsonApiOptions)testContext.Factory.Services.GetRequiredService <IJsonApiOptions>();

            options.AllowClientGeneratedIds = true;
        }
Esempio n. 10
0
        public WorkflowTests(ExampleIntegrationTestContext <ModelStateValidationStartup <WorkflowDbContext>, WorkflowDbContext> testContext)
        {
            _testContext = testContext;

            testContext.UseController <WorkflowsController>();

            testContext.ConfigureServicesAfterStartup(services =>
            {
                services.AddResourceDefinition <WorkflowDefinition>();
            });
        }
        public AtomicAbsoluteLinksTests(ExampleIntegrationTestContext <TestableStartup <OperationsDbContext>, OperationsDbContext> testContext)
        {
            _testContext = testContext;

            testContext.ConfigureServicesAfterStartup(services =>
            {
                services.AddControllersFromExampleProject();

                services.AddScoped(typeof(IResourceChangeTracker <>), typeof(NeverSameResourceChangeTracker <>));
            });
        }
        public AtomicResponseMetaTests(ExampleIntegrationTestContext <TestableStartup <OperationsDbContext>, OperationsDbContext> testContext)
        {
            _testContext = testContext;

            testContext.ConfigureServicesAfterStartup(services =>
            {
                services.AddControllersFromExampleProject();

                services.AddSingleton <IResponseMeta, AtomicResponseMeta>();
            });
        }
Esempio n. 13
0
        public AtomicResourceMetaTests(ExampleIntegrationTestContext <TestableStartup <OperationsDbContext>, OperationsDbContext> testContext)
        {
            _testContext = testContext;

            testContext.ConfigureServicesAfterStartup(services =>
            {
                services.AddControllersFromExampleProject();

                services.AddScoped <IResourceDefinition <MusicTrack, Guid>, MusicTrackMetaDefinition>();
                services.AddScoped <IResourceDefinition <TextLanguage, Guid>, TextLanguageMetaDefinition>();
            });
        }
Esempio n. 14
0
        public AtomicResourceMetaTests(ExampleIntegrationTestContext <TestableStartup <OperationsDbContext>, OperationsDbContext> testContext)
        {
            _testContext = testContext;

            testContext.UseController <OperationsController>();

            testContext.ConfigureServicesAfterStartup(services =>
            {
                services.AddResourceDefinition <MusicTrackMetaDefinition>();
                services.AddResourceDefinition <TextLanguageMetaDefinition>();
            });
        }
Esempio n. 15
0
        public CompositeKeyTests(ExampleIntegrationTestContext<TestableStartup<CompositeDbContext>, CompositeDbContext> testContext)
        {
            _testContext = testContext;

            testContext.ConfigureServicesAfterStartup(services =>
            {
                services.AddResourceRepository<CarRepository>();
            });

            var options = (JsonApiOptions) testContext.Factory.Services.GetRequiredService<IJsonApiOptions>();
            options.AllowClientGeneratedIds = true;
        }
        public ResourceMetaTests(ExampleIntegrationTestContext <TestableStartup <SupportDbContext>, SupportDbContext> testContext)
        {
            _testContext = testContext;

            testContext.UseController <ProductFamiliesController>();
            testContext.UseController <SupportTicketsController>();

            testContext.ConfigureServicesAfterStartup(services =>
            {
                services.AddResourceDefinition <SupportTicketDefinition>();
            });
        }
Esempio n. 17
0
        public AtomicRelativeLinksWithNamespaceTests(
            ExampleIntegrationTestContext <RelativeLinksInApiNamespaceStartup <OperationsDbContext>, OperationsDbContext> testContext)
        {
            _testContext = testContext;

            testContext.UseController <OperationsController>();

            testContext.ConfigureServicesAfterStartup(services =>
            {
                services.AddScoped(typeof(IResourceChangeTracker <>), typeof(NeverSameResourceChangeTracker <>));
            });
        }
Esempio n. 18
0
        public OutboxTests(ExampleIntegrationTestContext <TestableStartup <OutboxDbContext>, OutboxDbContext> testContext)
        {
            _testContext = testContext;

            testContext.UseController <DomainUsersController>();
            testContext.UseController <DomainGroupsController>();

            testContext.ConfigureServicesAfterStartup(services =>
            {
                services.AddResourceDefinition <OutboxUserDefinition>();
                services.AddResourceDefinition <OutboxGroupDefinition>();
            });
        }
Esempio n. 19
0
        public AbsoluteLinksWithNamespaceTests(ExampleIntegrationTestContext <AbsoluteLinksInApiNamespaceStartup <LinksDbContext>, LinksDbContext> testContext)
        {
            _testContext = testContext;

            testContext.ConfigureServicesAfterStartup(services =>
            {
                services.AddScoped(typeof(IResourceChangeTracker <>), typeof(NeverSameResourceChangeTracker <>));
            });

            var options = (JsonApiOptions)testContext.Factory.Services.GetRequiredService <IJsonApiOptions>();

            options.IncludeTotalResourceCount = true;
        }
Esempio n. 20
0
        public ResponseMetaTests(ExampleIntegrationTestContext <TestableStartup <SupportDbContext>, SupportDbContext> testContext)
        {
            _testContext = testContext;

            testContext.ConfigureServicesAfterStartup(services =>
            {
                services.AddSingleton <IResponseMeta, SupportResponseMeta>();
            });

            var options = (JsonApiOptions)testContext.Factory.Services.GetRequiredService <IJsonApiOptions>();

            options.IncludeTotalResourceCount = false;
        }
        public SparseFieldSetTests(ExampleIntegrationTestContext <TestableStartup <QueryStringDbContext>, QueryStringDbContext> testContext)
        {
            _testContext = testContext;

            testContext.ConfigureServicesAfterStartup(services =>
            {
                services.AddSingleton <ResourceCaptureStore>();

                services.AddResourceRepository <ResultCapturingRepository <Blog> >();
                services.AddResourceRepository <ResultCapturingRepository <BlogPost> >();
                services.AddResourceRepository <ResultCapturingRepository <WebAccount> >();
            });
        }
        public AtomicSparseFieldSetResourceDefinitionTests(ExampleIntegrationTestContext <TestableStartup <OperationsDbContext>, OperationsDbContext> testContext)
        {
            _testContext = testContext;

            testContext.ConfigureServicesAfterStartup(services =>
            {
                services.AddControllersFromExampleProject();

                services.AddSingleton <LyricPermissionProvider>();
                services.AddScoped <IResourceDefinition <Lyric, long>, LyricTextDefinition>();
                services.AddScoped(typeof(IResourceChangeTracker <>), typeof(NeverSameResourceChangeTracker <>));
            });
        }
        public TopLevelCountTests(ExampleIntegrationTestContext <TestableStartup <SupportDbContext>, SupportDbContext> testContext)
        {
            _testContext = testContext;

            testContext.ConfigureServicesAfterStartup(services =>
            {
                services.AddScoped(typeof(IResourceChangeTracker <>), typeof(NeverSameResourceChangeTracker <>));
            });

            var options = (JsonApiOptions)testContext.Factory.Services.GetRequiredService <IJsonApiOptions>();

            options.IncludeTotalResourceCount = true;
        }
Esempio n. 24
0
        public ArchiveTests(ExampleIntegrationTestContext <TestableStartup <TelevisionDbContext>, TelevisionDbContext> testContext)
        {
            _testContext = testContext;

            testContext.UseController <TelevisionNetworksController>();
            testContext.UseController <TelevisionStationsController>();
            testContext.UseController <TelevisionBroadcastsController>();
            testContext.UseController <BroadcastCommentsController>();

            testContext.ConfigureServicesAfterStartup(services =>
            {
                services.AddResourceDefinition <TelevisionBroadcastDefinition>();
            });
        }
Esempio n. 25
0
        public SerializationTests(ExampleIntegrationTestContext <TestableStartup <SerializationDbContext>, SerializationDbContext> testContext)
        {
            _testContext = testContext;

            testContext.ConfigureServicesAfterStartup(services =>
            {
                services.AddScoped(typeof(IResourceChangeTracker <>), typeof(NeverSameResourceChangeTracker <>));
            });

            var options = (JsonApiOptions)testContext.Factory.Services.GetRequiredService <IJsonApiOptions>();

            options.IncludeExceptionStackTraceInErrors = false;
            options.AllowClientGeneratedIds            = true;
        }
        public ResourceDefinitionQueryCallbackTests(ExampleIntegrationTestContext <TestableStartup <CallableDbContext>, CallableDbContext> testContext)
        {
            _testContext = testContext;

            testContext.ConfigureServicesAfterStartup(services =>
            {
                services.AddScoped <IResourceDefinition <CallableResource>, CallableResourceDefinition>();
                services.AddSingleton <IUserRolesService, FakeUserRolesService>();
            });

            var options = (JsonApiOptions)testContext.Factory.Services.GetRequiredService <IJsonApiOptions>();

            options.IncludeTotalResourceCount = true;
        }
        public AtomicAbsoluteLinksTests(ExampleIntegrationTestContext <TestableStartup <OperationsDbContext>, OperationsDbContext> testContext)
        {
            _testContext = testContext;

            testContext.UseController <OperationsController>();

            // These routes need to be registered in ASP.NET for rendering links to resource/relationship endpoints.
            testContext.UseController <TextLanguagesController>();
            testContext.UseController <RecordCompaniesController>();

            testContext.ConfigureServicesAfterStartup(services =>
            {
                services.AddScoped(typeof(IResourceChangeTracker <>), typeof(NeverSameResourceChangeTracker <>));
            });
        }
        public RelativeLinksWithoutNamespaceTests(ExampleIntegrationTestContext <RelativeLinksNoNamespaceStartup <LinksDbContext>, LinksDbContext> testContext)
        {
            _testContext = testContext;

            testContext.UseController <PhotoAlbumsController>();
            testContext.UseController <PhotosController>();

            testContext.ConfigureServicesAfterStartup(services =>
            {
                services.AddScoped(typeof(IResourceChangeTracker <>), typeof(NeverSameResourceChangeTracker <>));
            });

            var options = (JsonApiOptions)testContext.Factory.Services.GetRequiredService <IJsonApiOptions>();

            options.IncludeTotalResourceCount = true;
        }
Esempio n. 29
0
        public ResourceMetaTests(ExampleIntegrationTestContext <TestableStartup <SupportDbContext>, SupportDbContext> testContext)
        {
            _testContext = testContext;

            testContext.UseController <ProductFamiliesController>();
            testContext.UseController <SupportTicketsController>();

            testContext.ConfigureServicesAfterStartup(services =>
            {
                services.AddResourceDefinition <SupportTicketDefinition>();
                services.AddSingleton <ResourceDefinitionHitCounter>();
            });

            var hitCounter = _testContext.Factory.Services.GetRequiredService <ResourceDefinitionHitCounter>();

            hitCounter.Reset();
        }
Esempio n. 30
0
        public AtomicTransactionConsistencyTests(ExampleIntegrationTestContext <TestableStartup <OperationsDbContext>, OperationsDbContext> testContext)
        {
            _testContext = testContext;

            testContext.ConfigureServicesAfterStartup(services =>
            {
                services.AddControllersFromExampleProject();

                services.AddResourceRepository <PerformerRepository>();
                services.AddResourceRepository <MusicTrackRepository>();
                services.AddResourceRepository <LyricRepository>();

                string postgresPassword   = Environment.GetEnvironmentVariable("PGPASSWORD") ?? "postgres";
                string dbConnectionString = $"Host=localhost;Port=5432;Database=JsonApiTest-{Guid.NewGuid():N};User ID=postgres;Password={postgresPassword}";

                services.AddDbContext <ExtraDbContext>(options => options.UseNpgsql(dbConnectionString));
            });
        }