예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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;
        }