Пример #1
0
        public void CacheTenantSetupAndGetProperties()
        {
            var          dbId       = RandomNumberHelper.NextInteger();
            var          helper     = new TestContextHelper("test_in-memory_DB-" + dbId);
            var          context    = new JobAssistantContext(helper.Options);
            IMemoryCache cache      = new MemoryCache(new MemoryCacheOptions());
            var          resolver   = new CachingTenantResolver(context, cache, _loggerFactory);
            var          properties = resolver.GetProps();

            Assert.NotNull(properties);
            Assert.Empty(properties);
        }
Пример #2
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();

            services.AddSingleton(logger => Log.Logger);
            services.AddScoped <IRepository, Repository>();
            services.AddScoped <DbContext, JobAssistantContext>();

            var uniqueInMemoryDbId = RandomNumberHelper.NextInteger();

            services.AddDbContext <JobAssistantContext>(options => options.UseInMemoryDatabase("test_in-memory_DB-" + uniqueInMemoryDbId));

            services.AddMultitenancy <Tenant, CachingTenantResolver>();

            Log.Information("Finishing up in configuration of test-oriented framework services!");
        }