public async Task BeforeEachTest() { const string connectionStringEnvironmentVariable = "ASPNETCORE_FootballBanter_IntegrationTests_ConnectionString"; ConnectionString = Environment.GetEnvironmentVariable(connectionStringEnvironmentVariable, EnvironmentVariableTarget.Machine); if (ConnectionString == null) { throw new ApplicationException( $"Define connection string to integration tests database using environment variable: {connectionStringEnvironmentVariable}"); } using (var sqlConnection = new SqlConnection(ConnectionString)) { await ClearDatabase(sqlConnection); } Logger = Substitute.For <ILogger>(); EmailSender = Substitute.For <IEmailSender>(); PhrasesStartup.Initialize( ConnectionString, new ExecutionContextMock(Guid.NewGuid()), Logger, new EmailsConfiguration("*****@*****.**", "sendGridUser", "sendGridKey"), "key", null, null); PhraseModule = new PhrasesModule(); }
private void InitializeModule(ILifetimeScope autofacContainer) { var emailsConfiguration = new EmailsConfiguration(Configuration["EmailsConfiguration:FromEmail"], Configuration["EmailsConfiguration:SendGridUser"], Configuration["EmailsConfiguration:SendGridKey"]); var httpContextAccessor = autofacContainer.Resolve <IHttpContextAccessor>(); var executionContextAccessor = new ExecutionContextAccessor(httpContextAccessor); var eventBus = new EventBusRabbitMQ(_logger, GetRabbitMQConnection(), "football-banter", "Phrases"); PhrasesStartup.Initialize( Configuration["ConnectionString"], executionContextAccessor, _logger, emailsConfiguration, Configuration["Security:TextEncryptionKey"], null, eventBus ); }