private void ProcessAsDirectory(string sourcePath, string optionName, OptionsParser.ResultType resultType)
        {
            if (!Directory.Exists(sourcePath))
            {
                throw new ArgumentException(string.Format("{0} directory `{1}` cannot be found", optionName,
                                                          sourcePath));
            }

            var fileNames = GetAllFileNames(sourcePath).ToArray();

            if (!fileNames.Any())
            {
                throw new ArgumentException(string.Format("{0} directory `{1}` doesn't contain any {2} files.",
                                                          optionName,
                                                          sourcePath, FileType));
            }

            switch (resultType)
            {
            case OptionsParser.ResultType.Test:
                ResultDirectoryPaths.Add(sourcePath);
                break;

            case OptionsParser.ResultType.Baseline:
                foreach (var filename in fileNames)
                {
                    BaselineFilePaths.Add(filename);
                }

                break;

            default:
                throw new InvalidEnumArgumentException(resultType.ToString());
            }
        }
        private void ProcessAsXmlDirectory(string xmlSourcePath, string optionName, OptionsParser.ResultType resultType)
        {
            if (!Directory.Exists(xmlSourcePath))
            {
                throw new ArgumentException(string.Format("{0} directory `{1}` cannot be found", optionName,
                                                          xmlSourcePath));
            }

            var xmlFileNames = GetAllXmlFileNames(xmlSourcePath).ToArray();

            if (!xmlFileNames.Any())
            {
                throw new ArgumentException(string.Format("{0} directory `{1}` doesn't contain any .xml files.", optionName,
                                                          xmlSourcePath));
            }

            switch (resultType)
            {
            case OptionsParser.ResultType.Test:
                ResultXmlDirectoryPaths.Add(xmlSourcePath);
                break;

            case OptionsParser.ResultType.Baseline:
                BaselineXmlDirectoryPaths.Add(xmlSourcePath);
                break;

            default:
                throw new InvalidEnumArgumentException(resultType.ToString());
            }
        }
Ejemplo n.º 3
0
        private void ProcessAsXmlDirectory(string xmlSourcePath, string optionName, OptionsParser.ResultType resultType)
        {
            if (!Directory.Exists(xmlSourcePath))
            {
                throw new ArgumentException(string.Format("{0} directory `{1}` cannot be found", optionName,
                                                          xmlSourcePath));
            }

            var xmlFileNames = GetAllXmlFileNames(xmlSourcePath).ToArray();

            if (!xmlFileNames.Any())
            {
                throw new ArgumentException(string.Format("{0} directory `{1}` doesn't contain any .xml files.",
                                                          optionName,
                                                          xmlSourcePath));
            }

            ResultXmlDirectoryPaths.Add(xmlSourcePath);
        }
Ejemplo n.º 4
0
        private void ProcessAsXmlFile(string xmlSourcePath, string optionName, OptionsParser.ResultType resultType)
        {
            if (!File.Exists(xmlSourcePath))
            {
                throw new ArgumentException(string.Format("{0} file `{1}` cannot be found", optionName, xmlSourcePath));
            }

            switch (resultType)
            {
            case OptionsParser.ResultType.Test:
                ResultXmlFilePaths.Add(xmlSourcePath);
                break;

            case OptionsParser.ResultType.Baseline:
                BaselineXmlFilePaths.Add(xmlSourcePath);
                break;

            default:
                throw new InvalidEnumArgumentException(resultType.ToString());
            }
        }
Ejemplo n.º 5
0
        public void AddXmlSourcePath(string xmlSourcePath, string optionName, OptionsParser.ResultType resultType)
        {
            if (string.IsNullOrEmpty(xmlSourcePath))
            {
                throw new ArgumentNullException(xmlSourcePath);
            }

            if (string.IsNullOrEmpty(optionName))
            {
                throw new ArgumentNullException(optionName);
            }

            //If has .xml file extension
            if (xmlSourcePath.EndsWith(xmlFileExtension))
            {
                ProcessAsXmlFile(xmlSourcePath, optionName, resultType);
            }
            else
            {
                ProcessAsXmlDirectory(xmlSourcePath, optionName, resultType);
            }
        }
        public void AddSourcePath(string sourcePath, string optionName, OptionsParser.ResultType resultType)
        {
            System.Console.WriteLine($" Adding Source Path : {sourcePath}");
            System.Console.WriteLine($"");

            if (string.IsNullOrEmpty(sourcePath))
            {
                throw new ArgumentNullException(sourcePath);
            }

            if (string.IsNullOrEmpty(optionName))
            {
                throw new ArgumentNullException(optionName);
            }

            if (sourcePath.EndsWith(fileExtension.ToString()))
            {
                ProcessAsFile(sourcePath, optionName, resultType);
            }
            else
            {
                ProcessAsDirectory(sourcePath, optionName, resultType);
            }
        }