Example #1
0
        public TestExplorerViewModel(
            IEditorContext editorContext,
            ITestProvider testProvider,
            ITestRunner testRunner,
            IResultProvider resultProvider,
            ICoverageProvider coverageProvider,
            IOptions options,
            SelectTestCommand selectTestCommand,
            JumpToTestCommand jumpToTestCommand,
            RunTestCommand runTestCommand,
            CoverTestCommand coverTestCommand,
            DebugTestCommand debugTestCommand)
        {
            PassedStateGroup       = new TestStateGroupViewModel(TestState.Passed);
            InconclusiveStateGroup = new TestStateGroupViewModel(TestState.Inconclusive);
            FailedStateGroup       = new TestStateGroupViewModel(TestState.Failed);
            _stateGroups           = new Dictionary <TestState, TestStateGroupViewModel>()
            {
                { TestState.Passed, PassedStateGroup },
                { TestState.Inconclusive, InconclusiveStateGroup },
                { TestState.Failed, FailedStateGroup }
            };
            SearchViewModel = new CodeItemSearchViewModel <TestItemViewModel, TestItem>();

            _editorContext  = editorContext;
            _testProvider   = testProvider;
            _testRunner     = testRunner;
            _resultProvider = resultProvider;
            _options        = options;

            _editorContext.SolutionOpened  += OnSolutionOpened;
            _editorContext.SolutionClosing += OnSolutionClosing;
            _editorContext.BuildStarted    += OnBuildStarted;
            _editorContext.BuildFinished   += OnBuildFinished;

            _testProvider.ScanningStarted  += OnScanningStarted;
            _testProvider.ScanningFinished += OnScanningFinished;

            _testRunner.DebuggingStarted += OnDebuggingStarted;
            _testRunner.TestsStarted     += OnTestsStarted;
            _testRunner.TestStarted      += OnTestStarted;
            _testRunner.TestExecuted     += OnTestExecuted;
            _testRunner.TestLogAdded     += OnTestLogAdded;
            _testRunner.TestsFinished    += OnTestsFinished;
            _testRunner.TestsFailed      += OnTestsFailed;
            _testRunner.TestsAborted     += OnTestsAborted;

            _options.PropertyChanged += OnOptionChanged;

            selectTestCommand.CommandCalled += OnSelectTest;
            jumpToTestCommand.CommandCalled += OnJumpToTest;
            runTestCommand.CommandCalled    += OnRunTest;
            coverTestCommand.CommandCalled  += OnCoverTest;
            debugTestCommand.CommandCalled  += OnDebugTest;

            if (_editorContext.Solution.IsOpen)
            {
                LoadSolution();
            }
        }
Example #2
0
        public LineCoverageAdornment(
            IWpfTextView textView,
            ITextDocumentFactoryService documentFactory,
            ICoverageProvider coverageProvider,
            IResultProvider resultProvider,
            IOptions options,
            SelectTestCommand selectTestCommand,
            JumpToTestCommand jumpToTestCommand,
            DebugTestCommand debugTestCommand)
        {
            if (textView == null)
            {
                throw new ArgumentNullException(nameof(textView));
            }

            _options                    = options;
            _selectedBrushAndPen        = new BrushAndPenContainer(_options.SelectedColor, _branchCoverageSpotBorderThickness);
            _coveredBrushAndPen         = new BrushAndPenContainer(_options.CoveredColor, _branchCoverageSpotBorderThickness);
            _mixedBrushAndPen           = new BrushAndPenContainer(_options.MixedColor, _branchCoverageSpotBorderThickness);
            _uncoveredBrushAndPen       = new BrushAndPenContainer(_options.UncoveredColor, _branchCoverageSpotBorderThickness);
            _exceptionOriginBrushAndPen = new BrushAndPenContainer(_options.ExceptionOriginColor, _branchCoverageSpotBorderThickness);
            _exceptionTraceBrushAndPen  = new BrushAndPenContainer(_options.ExceptionTraceColor, _branchCoverageSpotBorderThickness);

            _brushesAndPens = new Dictionary <CoverageState, BrushAndPenContainer>()
            {
                { CoverageState.Unknown, new BrushAndPenContainer(Colors.Transparent, _branchCoverageSpotBorderThickness) },
                { CoverageState.Uncovered, _uncoveredBrushAndPen },
                { CoverageState.Mixed, _mixedBrushAndPen },
                { CoverageState.Covered, _coveredBrushAndPen }
            };

            _documentFactory = documentFactory;
            _textView        = textView;

            _coverageProvider = coverageProvider;
            _resultProvider   = resultProvider;

            _selectTestCommand = selectTestCommand;
            _jumpToTestCommand = jumpToTestCommand;
            _debugTestCommand  = debugTestCommand;

            TryInitilaizeFilePath();

            _adornmentLayer          = _textView.GetAdornmentLayer(TextViewCreationListener.CoverageAdornmentLayerName);
            _textView.LayoutChanged += OnLayoutChanged;

            _coverageProvider.CoverageUpdated += OnCoverageUpdated;
            _resultProvider.ResultsUpdated    += OnResultsUpdated;
            UpdateCoverage();
            UpdateResults();

            _options.PropertyChanged += OnOptionsPropertyChanged;
            _isHighlightingChanged   += UpdateAllLines;

            _textView.Closed += OnClosed;
        }
        public TestExplorerViewModel(IEditorContext editorContext, ITestProvider testProvider, ITestRunner testRunner, IResultProvider resultProvider, ICoverageProvider coverageProvider, IOptions options, SelectTestCommand selectTestCommand, JumpToTestCommand jumpToTestCommand, DebugTestCommand debugTestCommand)
        {
            SearchViewModel = new CodeItemSearchViewModel <TestItemViewModel, TestItem>();
            StateGroups     = new ObservableCollection <TestStateGroupViewModel>();

            _editorContext  = editorContext;
            _testProvider   = testProvider;
            _testRunner     = testRunner;
            _resultProvider = resultProvider;
            _options        = options;

            _editorContext.SolutionOpened  += OnSolutionOpened;
            _editorContext.SolutionClosing += OnSolutionClosing;
            _editorContext.BuildStarted    += OnBuildStarted;
            _editorContext.BuildFinished   += OnBuildFinished;

            _testProvider.ScanningStarted  += OnScanningStarted;
            _testProvider.ScanningFinished += OnScanningFinished;

            _testRunner.DebuggingStarted += OnDebuggingStarted;
            _testRunner.TestsStarted     += OnTestsStarted;
            _testRunner.TestStarted      += OnTestStarted;
            _testRunner.TestExecuted     += OnTestExecuted;
            _testRunner.TestLogAdded     += OnTestLogAdded;
            _testRunner.TestsFinished    += OnTestsFinished;
            _testRunner.TestsFailed      += OnTestsFailed;
            _testRunner.TestsAborted     += OnTestsAborted;

            _options.PropertyChanged += OnOptionChanged;

            selectTestCommand.CommandCalled += OnSelectTest;
            jumpToTestCommand.CommandCalled += OnJumpToTest;
            debugTestCommand.CommandCalled  += OnDebugTest;
        }