public PgFixture()
 {
     _pgRunner = PostgresRunner
                 .Start(new PostgresRunnerOptions {
         BinariesSearchPattern = "/pg-dist/pgsql-10.1-linux-binaries/bin"
     });
 }
예제 #2
0
 public PgFixture()
 {
     _pgRunner = PostgresRunner
                 .Start(new PostgresRunnerOptions {
         BinariesSearchPattern = GetPgBinariesRelativePath()
     });
 }
예제 #3
0
        public void Test1()
        {
            using (var runner = PostgresRunner.Start(options: new PostgresRunnerOptions()
            {
            }))
                using (var conn = new NpgsqlConnection(runner.GetConnectionString()))
                    using (var cmd = new NpgsqlCommand("select version()", conn))
                    {
                        conn.Open();
                        var version = cmd.ExecuteScalar() as string;

                        Console.WriteLine($"PostgreSQL version: {version}");
                    }
        }
예제 #4
0
        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 PgFixture()
 {
     _pgRunner = PostgresRunner.Start();
 }
예제 #6
0
        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);
            }
        }