Пример #1
0
        public bool OnOk()
        {
            if (Validation.GetHasError(testNamespaceRegExTextBox))
            {
                return(false);
            }
            if (Validation.GetHasError(testClassSuffixTextBox))
            {
                return(false);
            }
            if (Validation.GetHasError(unitTestTemplateTextBox))
            {
                return(false);
            }
            if (Validation.GetHasError(codeTemplateTextBox))
            {
                return(false);
            }

            if (Validation.GetHasError(SingleTestNamespaceRegExTextBox))
            {
                return(false);
            }
            if (Validation.GetHasError(SingleTestNamespaceToAssemblyRegExReplaceTextBox))
            {
                return(false);
            }
            if (Validation.GetHasError(SingleTestNamespaceToAssemblySubNameSpaceRegExReplaceTextBox))
            {
                return(false);
            }
            if (Validation.GetHasError(SingleTestCodeNamespaceRegExTextBox))
            {
                return(false);
            }
            if (Validation.GetHasError(SingleTestCodeNamespaceToTestRegExReplaceTextBox))
            {
                return(false);
            }

            var attributes = testingAttributesListBox.Items.Cast <string>().ToList().Join(",");

            _settings.SetValue((TestFileAnalysisSettings s) => s.TestingAttributeText, attributes);

            attributes = contextPrefixesListBox.Items.Cast <string>().ToList().Join(",");
            _settings.SetValue((TestFileAnalysisSettings s) => s.BddPrefix, attributes);

            _settings.SetValue((TestFileAnalysisSettings s) => s.FindAnyUsageInTestAssembly, ShowAllTestsWithUsageCheckBox.IsChecked);
            _settings.SetValue((TestFileAnalysisSettings s) => s.CheckTestNamespaces, CheckTestNamespaces.IsChecked);
            _settings.SetValue((TestFileAnalysisSettings s) => s.FindOrphanedProjectFiles, CheckSearchForOrphanedCodeFiles.IsChecked);

            _settings.SetValue((TestFileAnalysisSettings s) => s.OutputPanelOpenOnKeyboardMapping, OutputPanelOpenOnKeyboardMapping.IsChecked);

            var selectedItem = TestCopStrategyCombo.SelectedItem as ListBoxItem ?? new ListBoxItem()
            {
                Tag = TestProjectStrategy.TestProjectPerCodeProject
            };

            _settings.SetValue((TestFileAnalysisSettings s) => s.TestCopProjectStrategy, selectedItem.Tag);


            //RegEx Config for Multi Test via project naming
            _settings.SetValue((TestFileAnalysisSettings s) => s.TestProjectNameToCodeProjectNameRegEx,
                               testProjectNameRegExTextBox.Text.Replace(" ", ""));
            _settings.SetValue((TestFileAnalysisSettings s) => s.TestProjectNameToCodeProjectNameRegExReplace,
                               testProjectNameRegExReplaceTextBox.Text.Replace(" ", ""));
            //Regex Config for Multi Test Assemply Logic via project namespace
            _settings.SetValue((TestFileAnalysisSettings s) => s.TestClassSuffix,
                               testClassSuffixTextBox.Text.Replace(" ", ""));
            _settings.SetValue((TestFileAnalysisSettings s) => s.TestProjectToCodeProjectNameSpaceRegEx,
                               testNamespaceRegExTextBox.Text.Replace(" ", ""));
            _settings.SetValue((TestFileAnalysisSettings s) => s.TestProjectToCodeProjectNameSpaceRegExReplace,
                               testNamespaceRegExReplaceTextBox.Text.Replace(" ", ""));
            //Regex Config for Single Test Assemply Logic
            _settings.SetValue((TestFileAnalysisSettings s) => s.SingleTestRegexTestToAssembly,
                               SingleTestNamespaceRegExTextBox.Text.Replace(" ", ""));
            _settings.SetValue((TestFileAnalysisSettings s) => s.SingleTestRegexTestToAssemblyProjectReplace,
                               SingleTestNamespaceToAssemblyRegExReplaceTextBox.Text.Replace(" ", ""));
            _settings.SetValue((TestFileAnalysisSettings s) => s.SingleTestRegexTestToAssemblyProjectSubNamespaceReplace,
                               SingleTestNamespaceToAssemblySubNameSpaceRegExReplaceTextBox.Text.Replace(" ", ""));
            _settings.SetValue((TestFileAnalysisSettings s) => s.SingleTestRegexCodeToTestAssembly,
                               SingleTestCodeNamespaceRegExTextBox.Text.Replace(" ", ""));
            _settings.SetValue((TestFileAnalysisSettings s) => s.SingleTestRegexCodeToTestReplace,
                               SingleTestCodeNamespaceToTestRegExReplaceTextBox.Text.Replace(" ", ""));
            //
            _settings.SetValue((TestFileAnalysisSettings s) => s.CodeFileTemplateName, codeTemplateTextBox.Text);
            _settings.SetValue((TestFileAnalysisSettings s) => s.UnitTestFileTemplateName, unitTestTemplateTextBox.Text);

            _settings.SetValue((TestFileAnalysisSettings s) => s.SupportRenameRefactor, SupportRenameRefactor.IsChecked);
            _settings.SetValue((TestFileAnalysisSettings s) => s.OrphanedFilesPatterns, OrphanedFilesPatternsTextBox.Text);

            DTEHelper.AssignKeyboardShortcutIfMissing(
                true, ResharperHelper.MacroNameSwitchBetweenFiles, SwitchBetweenFilesShortcutTextBox.Text);

            _settings.SetValue((TestFileAnalysisSettings s) => s.ShortcutToSwitchBetweenFiles, SwitchBetweenFilesShortcutTextBox.Text);

            DTEHelper.AssignKeyboardShortcutIfMissing(
                true, ResharperHelper.MacroNameRunTests, RunTestsShortcutTextBox.Text);

            _settings.SetValue((TestFileAnalysisSettings s) => s.ShortcutToRunTests, RunTestsShortcutTextBox.Text);

            return(true);
        }