예제 #1
0
        private void LoadTestScripts()
        {
            // Load all files ending in ".sql". Note that due to strange Win32 behavior we need to double check the
            // file name actually ends in ".sql" since suffixes like ".sqlOther" would also be included in the results
            DirectoryInfo di = new DirectoryInfo(ScriptsFolder);
            var           scriptFilepaths = from file in di.GetFiles("*" + SqlExt)
                                            where SqlExt.Equals(file.Extension, StringComparison.OrdinalIgnoreCase)
                                            select file.FullName;

            foreach (string scriptFile in scriptFilepaths)
            {
                try
                {
                    string contents = RuleTestUtils.ReadFileToString(scriptFile);
                    TestScripts.Add(Tuple.Create(contents, scriptFile));
                    Console.WriteLine("Test script file '{0}' loaded", scriptFile);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(
                        "Error reading from file '{0}', message is '{1}'. Continuing processing since missing files treated as warning for test",
                        scriptFile,
                        ex.Message);
                }
            }
        }
예제 #2
0
        private void LoadTestScripts(string folder)
        {
            if (!Directory.Exists(folder))
            {
                return;
            }

            DirectoryInfo directoryInfo = new DirectoryInfo(folder);

            var scriptFilePaths = from file in directoryInfo.GetFiles("*" + SqlExtension)
                                  where SqlExtension.Equals(file.Extension, StringComparison.OrdinalIgnoreCase)
                                  select file.FullName;

            foreach (string scriptFile in scriptFilePaths)
            {
                try
                {
                    string contents = RuleTestUtils.ReadFileToString(scriptFile);
                    TestScripts.Add(Tuple.Create(contents, Path.GetFileName(scriptFile)));
                    Console.WriteLine($"Test file '{scriptFile}' loaded successfully");
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"Error reading from file {scriptFile} with message '{ex.Message}'");
                    Console.WriteLine("Execution will continue...");
                }
            }
        }