protected HttpClient GetClient()
        {
            int    randomPort    = RandomNumberHelper.NextIntegerInRange(5120, 6144);
            string httpServerUrl = String.Format("http://*:{0}", randomPort);

            var host = new WebHostBuilder()
                       .UseKestrel()
                       .UseContentRoot(Directory.GetCurrentDirectory())
                       .UseStartup <Startup>()
                       .UseUrls(httpServerUrl)
                       .Build();

            host.Start();

            Thread.Sleep(3000);

            var client = new HttpClient {
                BaseAddress = new Uri(httpServerUrl)
            };

            client.DefaultRequestHeaders.Accept.Clear();
            // Client always expects JSON results
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            // TODO: Switch over to using the RestSharp client
            return(client);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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!");
        }
Ejemplo n.º 4
0
        protected RestClient GetClient()
        {
            int    randomPort    = RandomNumberHelper.NextIntegerInRange(5120, 8191);
            string httpServerUrl = String.Format("http://*:{0}", randomPort);
            string httpClientUrl = String.Format("http://localhost:{0}", randomPort);

            _host = new WebHostBuilder()
                    .UseKestrel()
                    .UseContentRoot(Directory.GetCurrentDirectory())
                    .UseStartup <Startup>()
                    .UseUrls(httpServerUrl)
                    .Build();

            _host.Start();

            Thread.Sleep(3000);

            return(new RestClient(httpClientUrl));
        }