public void DbEnvironmentReadTestWithEmptyInputTest() { var dbCredentials = new Dictionary <string, string>(); var configUnderTest = new DbEnvironmentConfig(dbCredentials); Assert.NotNull(configUnderTest); var connectionString = configUnderTest.GenerateMySqlConnectionString(); Assert.Equal(@"server=(null);database=(null);uid=(null);pwd=(null);", connectionString); }
public void DbEnvironmentReadTestWithMissingVariablesTest() { var dbCredentials = new Dictionary <string, string> { { "MYSQL_SERVER", "localhost" }, { "MYSQL_DATABASE", "JobAssistant" } }; var configUnderTest = new DbEnvironmentConfig(dbCredentials); Assert.NotNull(configUnderTest); var connectionString = configUnderTest.GenerateMySqlConnectionString(); Assert.Equal(@"server=localhost;database=JobAssistant;uid=(null);pwd=(null);", connectionString); }
public void DbEnvironmentReadTest() { var dbCredentials = new Dictionary <string, string> { { "MYSQL_SERVER", "localhost" }, { "MYSQL_DATABASE", "JobAssistant" }, { "MYSQL_USER_ID", "root" }, { "MYSQL_USER_PASSWORD", "MiSs-5.7.17$" } }; var configUnderTest = new DbEnvironmentConfig(dbCredentials); Assert.NotNull(configUnderTest); var connectionString = configUnderTest.GenerateMySqlConnectionString(); Assert.Equal(@"server=localhost;database=JobAssistant;uid=root;pwd=MiSs-5.7.17$;", connectionString); }
public TestContextHelper(string environmentClass) { var optionsBuilder = new DbContextOptionsBuilder <JobAssistantContext>(); if (!string.IsNullOrEmpty(environmentClass) && environmentClass.Contains("test")) { optionsBuilder.UseInMemoryDatabase(environmentClass); } else { var envConfig = new DbEnvironmentConfig(new Dictionary <string, string> { { "MYSQL_SERVER", "localhost" }, { "MYSQL_DATABASE", "JobAssistant" }, { "MYSQL_USER_ID", "root" }, { "MYSQL_USER_PASSWORD", "MiSs-5.7.17$" } }); string mySqlConnectionString = envConfig.GenerateMySqlConnectionString(); optionsBuilder.UseMySql(mySqlConnectionString); } this.Options = optionsBuilder.Options; }