public TestServerFixture() { try { runner = PostgresRunner.Start(new PostgresRunnerOptions() { Port = 5432 }); MontaBaseDados(runner); var projectPath = GetContentRootPath("../src/SME.SGP.Api"); var builderCliente = new WebHostBuilder() .UseContentRoot(projectPath) .UseEnvironment("teste-integrado") .UseConfiguration(new ConfigurationBuilder() .SetBasePath(projectPath) .AddJsonFile("appsettings.teste-integrado.json") .Build()) .UseStartup <Startup>(); _testServerCliente = new TestServer(builderCliente); _clientApi = _testServerCliente.CreateClient(); var config = new ConfigurationBuilder() .AddJsonFile(ObterArquivoConfiguracao(), optional: false) .Build(); //TODO: INJETAR UM REPOSITORIO DE CACHE E HTTPCONTEXT var repositorioCache = new Mock <RepositorioCache>(); servicoTokenJwt = new ServicoTokenJwt(config, null, repositorioCache.Object); } catch (Exception ex) { if (runner != null) { runner.Dispose(); } throw new Exception(ex.Message); } }
public TestServerFixture() { try { Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); _postgresRunner = PostgresRunner.Start(new PostgresRunnerOptions() { Port = 5434 }); MontaBaseDados(_postgresRunner); _redisRunner = RedisRunner.Start(); Environment.SetEnvironmentVariable("ApplicationInsights__InstrumentationKey", "ab"); var projectPath = GetContentRootPath("../src/SME.SGP.Api"); var servicoLog = new Mock <IServicoLog>(); servicoLog.Setup(sl => sl.Registrar(new Exception())); servicoLog.Setup(sl => sl.Registrar(string.Empty)); var builderCliente = new WebHostBuilder() .UseContentRoot(projectPath) .ConfigureServices(services => { services.AddSingleton <IConnectionMultiplexerSME>(new ConnectionMultiplexerSME($"localhost:{_redisRunner.Port}", servicoLog.Object)); }) .UseEnvironment("teste-integrado") .UseConfiguration(new ConfigurationBuilder() .SetBasePath(projectPath) .AddJsonFile("appsettings.teste-integrado.json") .Build()) .UseStartup <Startup>(); _testServerCliente = new TestServer(builderCliente); _clientApi = _testServerCliente.CreateClient(); var config = new ConfigurationBuilder() .AddJsonFile(ObterArquivoConfiguracao(), optional: false) .Build(); var contextoTesteIntegrado = new ContextoTesteIntegrado(""); servicoTokenJwt = new ServicoTokenJwt(config, contextoTesteIntegrado); } catch (Exception ex) { if (_postgresRunner != null) { _postgresRunner.Dispose(); } if (_redisRunner != null) { _redisRunner.Dispose(); } throw new Exception(ex.Message); } }