Exemplo n.º 1
0
        public void Configure(string dbName, ITestOutputHelper testOutputHelper)
        {
            var bioEngine = new BioEngine(new string[0]);

            bioEngine.ConfigureServices(collection =>
            {
                collection.AddLogging(o => o.AddProvider(new XunitLoggerProvider(testOutputHelper)));
                ConfigureServices(collection, dbName);
            })
            .AddEntities();

            var config = new ConfigurationBuilder()
                         .AddEnvironmentVariables()
                         .AddUserSecrets <TScope>()
                         .Build();

            var testInMemory =
                !string.IsNullOrEmpty(config["BIOENGINE_TEST_IN_MEMORY"]) &&
                bool.TryParse(config["BIOENGINE_TEST_IN_MEMORY"], out var outBool) && outBool;

            if (testInMemory)
            {
                bioEngine.AddModule <InMemoryDatabaseModule <BioContext>, InMemoryDatabaseModuleConfig>(
                    (configuration, environment) => new InMemoryDatabaseModuleConfig(dbName));
            }
            else
            {
                bioEngine.AddModule <PostgresDatabaseModule <BioContext>, PostgresDatabaseModuleConfig>((configuration,
                                                                                                         environment) =>
                {
                    return(new PostgresDatabaseModuleConfig(config["BE_POSTGRES_HOST"],
                                                            config["BE_POSTGRES_USERNAME"], dbName,
                                                            config["BE_POSTGRES_PASSWORD"],
                                                            int.Parse(config["BE_POSTGRES_PORT"]))
                    {
                        EnableSensitiveLogging = true
                    });
                });
            }

            bioEngine       = ConfigureBioEngine(bioEngine);
            ServiceProvider = bioEngine.GetServices();
        }
Exemplo n.º 2
0
 protected override BioEngine ConfigureBioEngine(BioEngine bioEngine)
 {
     base.ConfigureBioEngine(bioEngine);
     return(bioEngine.AddModule <TestsModule>());
 }
Exemplo n.º 3
0
 protected virtual BioEngine ConfigureBioEngine(BioEngine bioEngine)
 {
     return(bioEngine);
 }