public TestExplorerViewModel(ISelectionService selectionService,
                                     TestExplorerModel model,
                                     IClipboardWriter clipboard,
                                     // ReSharper disable once UnusedParameter.Local - left in place because it will likely be needed for app wide font settings, etc.
                                     IGeneralConfigService configService,
                                     ISettingsFormFactory settingsFormFactory)
        {
            _clipboard           = clipboard;
            _settingsFormFactory = settingsFormFactory;

            NavigateCommand         = new NavigateCommand(selectionService);
            RunSingleTestCommand    = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteSingleTestCommand, CanExecuteSingleTest);
            RunSelectedTestsCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteSelectedTestsCommand, CanExecuteSelectedTestsCommand);
            RunSelectedGroupCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteRunSelectedGroupCommand, CanExecuteSelectedGroupCommand);
            CancelTestRunCommand    = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteCancelTestRunCommand, CanExecuteCancelTestRunCommand);
            ResetResultsCommand     = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteResetResultsCommand, CanExecuteResetResultsCommand);
            CopyResultsCommand      = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteCopyResultsCommand);
            OpenTestSettingsCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), OpenSettings);
            CollapseAllCommand      = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteCollapseAll);
            ExpandAllCommand        = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteExpandAll);

            Model = model;
            Model.TestCompleted += HandleTestCompletion;

            if (CollectionViewSource.GetDefaultView(Model.Tests) is ListCollectionView tests)
            {
                tests.SortDescriptions.Add(new SortDescription("QualifiedName.QualifiedModuleName.Name", ListSortDirection.Ascending));
                tests.SortDescriptions.Add(new SortDescription("QualifiedName.MemberName", ListSortDirection.Ascending));
                Tests = tests;
            }

            OnPropertyChanged(nameof(Tests));
            TestGrouping = TestExplorerGrouping.Outcome;
        }
Example #2
0
        public TestExplorerViewModel(ISelectionService selectionService,
                                     TestExplorerModel model,
                                     IClipboardWriter clipboard,
                                // ReSharper disable once UnusedParameter.Local - left in place because it will likely be needed for app wide font settings, etc.
#pragma warning disable IDE0060 // Remove unused parameter
                                     IConfigurationService <Configuration> configService,
#pragma warning restore IDE0060 // Remove unused parameter
                                     ISettingsFormFactory settingsFormFactory,
                                     IRewritingManager rewritingManager,
                                     IAnnotationUpdater annotationUpdater)
        {
            _clipboard           = clipboard;
            _settingsFormFactory = settingsFormFactory;

            NavigateCommand              = new NavigateCommand(selectionService);
            RunSingleTestCommand         = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteSingleTestCommand, CanExecuteSingleTest);
            RunSelectedTestsCommand      = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteSelectedTestsCommand, CanExecuteSelectedCommands);
            RunSelectedGroupCommand      = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteRunSelectedGroupCommand, CanExecuteGroupCommand);
            CancelTestRunCommand         = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteCancelTestRunCommand, CanExecuteCancelTestRunCommand);
            ResetResultsCommand          = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteResetResultsCommand, CanExecuteResetResultsCommand);
            CopyResultsCommand           = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteCopyResultsCommand);
            OpenTestSettingsCommand      = new DelegateCommand(LogManager.GetCurrentClassLogger(), OpenSettings);
            CollapseAllCommand           = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteCollapseAll);
            ExpandAllCommand             = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteExpandAll);
            IgnoreTestCommand            = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteIgnoreTestCommand, CanExecuteIgnoreTestCommand);
            UnignoreTestCommand          = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteUnignoreTestCommand, CanExecuteUnignoreTestCommand);
            IgnoreSelectedTestsCommand   = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteIgnoreSelectedTestsCommand, CanExecuteIgnoreSelectedTests);
            UnignoreSelectedTestsCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteUnignoreSelectedTestsCommand, CanExecuteUnignoreSelectedTests);
            IgnoreGroupCommand           = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteIgnoreGroupCommand, CanExecuteIgnoreGroupCommand);
            UnignoreGroupCommand         = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteUnignoreGroupCommand, CanExecuteUnignoreGroupCommand);

            RewritingManager  = rewritingManager;
            AnnotationUpdater = annotationUpdater;

            Model = model;

            if (CollectionViewSource.GetDefaultView(Model.Tests) is ListCollectionView tests)
            {
                tests.SortDescriptions.Add(new SortDescription("QualifiedName.QualifiedModuleName.Name", ListSortDirection.Ascending));
                tests.SortDescriptions.Add(new SortDescription("QualifiedName.MemberName", ListSortDirection.Ascending));
                tests.IsLiveFiltering = true;
                tests.IsLiveGrouping  = true;
                Tests = tests;
            }



            OnPropertyChanged(nameof(Tests));
            TestGrouping = TestExplorerGrouping.Outcome;

            OutcomeFilter = TestExplorerOutcomeFilter.All;
        }
Example #3
0
        public TestExplorerViewModel(IVBE vbe,
                                     RubberduckParserState state,
                                     ITestEngine testEngine,
                                     TestExplorerModel model,
                                     IClipboardWriter clipboard,
                                     IGeneralConfigService configService,
                                     ISettingsFormFactory settingsFormFactory,
                                     IMessageBox messageBox)
        {
            _vbe        = vbe;
            _state      = state;
            _testEngine = testEngine;
            _testEngine.TestCompleted += TestEngineTestCompleted;
            Model                = model;
            _clipboard           = clipboard;
            _settingsFormFactory = settingsFormFactory;
            _messageBox          = messageBox;

            _navigateCommand = new NavigateCommand(_state.ProjectsProvider);

            RunAllTestsCommand = new RunAllTestsCommand(vbe, state, testEngine, model, null);
            RunAllTestsCommand.RunCompleted += RunCompleted;

            AddTestModuleCommand      = new AddTestModuleCommand(vbe, state, configService, _messageBox);
            AddTestMethodCommand      = new AddTestMethodCommand(vbe, state);
            AddErrorTestMethodCommand = new AddTestMethodExpectedErrorCommand(vbe, state);

            RefreshCommand              = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteRefreshCommand, CanExecuteRefreshCommand);
            RepeatLastRunCommand        = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteRepeatLastRunCommand, CanExecuteRepeatLastRunCommand);
            RunNotExecutedTestsCommand  = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteRunNotExecutedTestsCommand, CanExecuteRunNotExecutedTestsCommand);
            RunInconclusiveTestsCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteRunInconclusiveTestsCommand, CanExecuteRunInconclusiveTestsCommand);
            RunFailedTestsCommand       = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteRunFailedTestsCommand, CanExecuteRunFailedTestsCommand);
            RunPassedTestsCommand       = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteRunPassedTestsCommand, CanExecuteRunPassedTestsCommand);
            RunSelectedTestCommand      = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteSelectedTestCommand, CanExecuteSelectedTestCommand);

            CopyResultsCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteCopyResultsCommand);

            OpenTestSettingsCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), OpenSettings);

            SetOutcomeGroupingCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), param =>
            {
                GroupByOutcome  = (bool)param;
                GroupByLocation = !(bool)param;
            });

            SetLocationGroupingCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), param =>
            {
                GroupByLocation = (bool)param;
                GroupByOutcome  = !(bool)param;
            });
        }
Example #4
0
        public TestExplorerViewModel(VBE vbe,
                                     RubberduckParserState state,
                                     ITestEngine testEngine,
                                     TestExplorerModel model,
                                     IClipboardWriter clipboard,
                                     NewUnitTestModuleCommand newTestModuleCommand,
                                     NewTestMethodCommand newTestMethodCommand,
                                     IGeneralConfigService configService,
                                     IOperatingSystem operatingSystem)
        {
            _state      = state;
            _testEngine = testEngine;
            _testEngine.TestCompleted += TestEngineTestCompleted;
            _model           = model;
            _clipboard       = clipboard;
            _configService   = configService;
            _operatingSystem = operatingSystem;

            _navigateCommand = new NavigateCommand();

            _runAllTestsCommand = new RunAllTestsCommand(state, testEngine, model);
            _runAllTestsCommand.RunCompleted += RunCompleted;

            _addTestModuleCommand      = new AddTestModuleCommand(vbe, state, newTestModuleCommand);
            _addTestMethodCommand      = new AddTestMethodCommand(vbe, state, newTestMethodCommand);
            _addErrorTestMethodCommand = new AddTestMethodExpectedErrorCommand(vbe, state, newTestMethodCommand);

            _refreshCommand             = new DelegateCommand(ExecuteRefreshCommand, CanExecuteRefreshCommand);
            _repeatLastRunCommand       = new DelegateCommand(ExecuteRepeatLastRunCommand, CanExecuteRepeatLastRunCommand);
            _runNotExecutedTestsCommand = new DelegateCommand(ExecuteRunNotExecutedTestsCommand, CanExecuteRunNotExecutedTestsCommand);
            _runFailedTestsCommand      = new DelegateCommand(ExecuteRunFailedTestsCommand, CanExecuteRunFailedTestsCommand);
            _runPassedTestsCommand      = new DelegateCommand(ExecuteRunPassedTestsCommand, CanExecuteRunPassedTestsCommand);
            _runSelectedTestCommand     = new DelegateCommand(ExecuteSelectedTestCommand, CanExecuteSelectedTestCommand);

            _copyResultsCommand = new DelegateCommand(ExecuteCopyResultsCommand);

            _openTestSettingsCommand = new DelegateCommand(OpenSettings);

            _setOutcomeGroupingCommand = new DelegateCommand(param =>
            {
                GroupByOutcome  = (bool)param;
                GroupByLocation = !(bool)param;
            });

            _setLocationGroupingCommand = new DelegateCommand(param =>
            {
                GroupByLocation = (bool)param;
                GroupByOutcome  = !(bool)param;
            });
        }
        public TestExplorerViewModel(IVBE vbe,
                                     RubberduckParserState state,
                                     ITestEngine testEngine,
                                     TestExplorerModel model,
                                     IClipboardWriter clipboard,
                                     IGeneralConfigService configService,
                                     ISettingsFormFactory settingsFormFactory,
                                     IMessageBox messageBox,
                                     ReparseCommand reparseCommand)
        {
            _vbe        = vbe;
            _state      = state;
            _testEngine = testEngine;
            _testEngine.TestCompleted += TestEngineTestCompleted;
            Model                = model;
            _clipboard           = clipboard;
            _settingsFormFactory = settingsFormFactory;
            _messageBox          = messageBox;

            _navigateCommand = new NavigateCommand(_state.ProjectsProvider);

            RunSelectedTestCommand          = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteSelectedTestCommand, CanExecuteSelectedTestCommand);
            RunSelectedCategoryTestsCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteRunSelectedCategoryTestsCommand, CanExecuteRunSelectedCategoryTestsCommand);

            CopyResultsCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), ExecuteCopyResultsCommand);

            OpenTestSettingsCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), OpenSettings);

            SetOutcomeGroupingCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), param =>
            {
                GroupByOutcome = true;

                if ((bool)param)
                {
                    GroupByLocation = false;
                    GroupByCategory = false;
                }
            });

            SetLocationGroupingCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), param =>
            {
                GroupByLocation = true;

                if ((bool)param)
                {
                    GroupByOutcome  = false;
                    GroupByCategory = false;
                }
            });

            SetCategoryGroupingCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), param =>
            {
                GroupByCategory = true;

                if ((bool)param)
                {
                    GroupByOutcome  = false;
                    GroupByLocation = false;
                }
            });
        }