IsInvalidDirName() публичный статический Метод

public static IsInvalidDirName ( string testSuiteName ) : bool
testSuiteName string
Результат bool
Пример #1
0
        private void _okButton_Click(object sender, RoutedEventArgs e)
        {
            var testSuiteName = TestSuiteName;

            if (string.IsNullOrWhiteSpace(testSuiteName))
            {
                MessageBox.Show(this, "Name of test suite can't be empty.", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                _testSuiteName.Focus();
                return;
            }

            var root = Path.GetFullPath(_model.RootFolder);
            var path = _model.SuitPath;

            if (Directory.Exists(path) && _model.IsCreate)
            {
                MessageBox.Show(this, "The test suite '" + testSuiteName + "' already exists.", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                _testSuiteName.Focus();
                return;
            }

            if (Utils.IsInvalidDirName(testSuiteName))
            {
                MessageBox.Show(this, "Name of test suite is invalid.", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                _testSuiteName.Focus();
                return;
            }

            var assemblies = _model.NormalizedAssemblies;

            if (assemblies.Length == 0)
            {
                MessageBox.Show(this, "No one valid library in library list.", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                _assemblies.Focus();
                return;
            }

            var selectedLanguage = _model.SelectedLanguage;

            if (selectedLanguage == null)
            {
                MessageBox.Show(this, "Langauge is not selected.", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                _languageComboBox.Focus();
                return;
            }

            try
            {
                Directory.CreateDirectory(path);
                if (_baseTestSuite != null && _baseTestSuite.Name != testSuiteName && Directory.Exists(_baseTestSuite.FullPath))
                {
                    FileSystem.CopyDirectory(_baseTestSuite.FullPath, path, UIOption.AllDialogs);
                    Directory.Delete(_baseTestSuite.FullPath, recursive: true);
                }

                var dynamicExtensions = _model.DynamicExtensions.Where(x => x.IsEnabled && x.IsChecked).Select(x => x.Descriptor);
                var xml        = Utils.MakeXml(root, selectedLanguage, dynamicExtensions, _model.NormalizedLibs, _model.IsSemanticAnalysisDisabled);
                var configPath = Path.Combine(path, TestSuiteVm.ConfigFileName);
                File.WriteAllText(configPath, xml);
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.GetType().Name + ":" + ex.Message, "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            this.DialogResult = true;
            Close();
        }
Пример #2
0
        private void _okButton_Click(object sender, RoutedEventArgs e)
        {
            var testSuiteName = TestSuiteName;

            if (string.IsNullOrWhiteSpace(testSuiteName))
            {
                MessageBox.Show(this, "Name of test suite can't be empty.", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                _testSuiteName.Focus();
                return;
            }

            var path = ViewModel.SuitPath;

            if (Directory.Exists(path) && ViewModel.IsCreate)
            {
                MessageBox.Show(this, "The test suite '" + testSuiteName + "' already exists.", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                _testSuiteName.Focus();
                return;
            }

            if (Utils.IsInvalidDirName(testSuiteName))
            {
                MessageBox.Show(this, "Name of test suite is invalid.", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                _testSuiteName.Focus();
                return;
            }

            var assemblies = ViewModel.ParserLibs;

            if (assemblies.Count == 0)
            {
                MessageBox.Show(this, "No one valid library in library list.", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            var selectedLanguage = ViewModel.SelectedLanguage;

            if (selectedLanguage == null)
            {
                MessageBox.Show(this, "Langauge is not selected.", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                Languages.Focus();
                return;
            }

            try
            {
                Directory.CreateDirectory(path);
                if (_baseSuite != null && !string.IsNullOrEmpty(_baseSuite.Name) && _baseSuite.Name != testSuiteName && Directory.Exists(_baseSuite.FullPath))
                {
                    FileSystem.CopyDirectory(_baseSuite.FullPath, path, UIOption.AllDialogs);
                    Directory.Delete(_baseSuite.FullPath, recursive: true);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.GetType().Name + ":" + ex.Message, "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            this.DialogResult = true;
            Close();
        }
Пример #3
0
        private void _okButton_Click(object sender, RoutedEventArgs e)
        {
            var testSuitName = _testSuitName.Text;

            if (string.IsNullOrWhiteSpace(testSuitName))
            {
                MessageBox.Show(this, "Name of test suit can't be empty.", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                _testSuitName.Focus();
                return;
            }

            var root = Path.GetFullPath(_rootFolder);
            var path = Path.Combine(root, testSuitName);

            if (Directory.Exists(path) && _create)
            {
                MessageBox.Show(this, "The test suit '" + testSuitName + "' already exists.", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                _testSuitName.Focus();
                return;
            }

            if (Utils.IsInvalidDirName(testSuitName))
            {
                MessageBox.Show(this, "Name of test suit is invalid.", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                _testSuitName.Focus();
                return;
            }

            MakeAllPathsRelative();

            var assemblyPaths = Utils.GetAssemblyPaths(_assemblies.Text);

            if (assemblyPaths.Length == 0)
            {
                MessageBox.Show(this, "No one valid library in library list.", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                _assemblies.Focus();
                return;
            }

            var syntaxModules = GetSelectedGrammarDescriptor();

            if (syntaxModules.Length == 0)
            {
                MessageBox.Show(this, "No syntax module is selected.", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                _syntaxModules.Focus();
                return;
            }

            var startRule = _startRuleComboBox.SelectedItem as RuleDescriptor;

            if (startRule == null)
            {
                MessageBox.Show(this, "No a start rule is selected.", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                _syntaxModules.Focus();
                return;
            }

            try
            {
                if (_baseTestSuit.Name != testSuitName && Directory.Exists(_baseTestSuit.FullPath))
                {
                    Directory.CreateDirectory(path);
                    FileSystem.CopyDirectory(_baseTestSuit.FullPath, path, UIOption.AllDialogs);
                    Directory.Delete(_baseTestSuit.FullPath, recursive: true);
                }
                else
                {
                    Directory.CreateDirectory(path);
                }

                var xml        = Utils.MakeXml(root, syntaxModules, startRule);
                var configPath = Path.Combine(path, "config.xml");
                xml.Save(configPath);
                TestSuitName = testSuitName;
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.GetType().Name + ":" + ex.Message, "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            this.DialogResult = true;
            Close();
        }