コード例 #1
0
        public void T01_ShouldReadTestsConfig()
        {
            var cfg = TestsConfig.Load();

            Assert.NotNull(cfg);
            Assert.False(string.IsNullOrEmpty(cfg.ConnectionStringTemplate));
        }
コード例 #2
0
        static string GetSqlConnectionString(string memberName)
        {
            var cfg = TestsConfig.Load();
            var csb = new SqlConnectionStringBuilder(cfg.ConnectionStringTemplate);

            csb.InitialCatalog += memberName;
            var result = csb.ConnectionString;
            var dbName = csb.InitialCatalog;

            {
                if (SqlUtils.DbExists(result))
                {
                    SqlUtils.DropDb(result);
                }
                SqlUtils.CreateDb(result);
            }
            return(result);
        }
コード例 #3
0
        public static TestsConfig Load(string fn = null)
        {
            if (string.IsNullOrEmpty(fn))
            {
                fn = DefaultFileName;
            }
            TestsConfig result;

            if (!File.Exists(fn))
            {
                result = new TestsConfig
                {
                    ConnectionStringTemplate =
                        "Server=(localdb)\\ShamanTests;Database=ShamanTests_;Integrated Security=true"
                };
                result.Save(fn);
                return(result);
            }
            string json = File.ReadAllText(fn);

            result = JsonConvert.DeserializeObject <TestsConfig>(json);
            return(result);
        }