Ejemplo n.º 1
0
        private void OnTestExecuted(object sender, EventArgs <TestResult> e)
        {
            //Update test item view model and state groups
            var testItem = TestSolution.FindChild(e.Value.Method);

            if (testItem != null)
            {
                testItem.Result.Results.Add(e.Value);
                testItem.State = testItem.Result.Results.Max(p => p.Outcome);
                _testsExecuted++;

                var resultItem = testItem.CreateResultViewModel(e.Value);

                var stateGroup = StateGroups.FirstOrDefault(p => p.State == resultItem.State);
                if (stateGroup == null)
                {
                    stateGroup = new TestStateGroupViewModel(resultItem.State);
                    StateGroups.OrderedAdd(stateGroup, (a, b) => a.State.CompareTo(b.State));
                }

                stateGroup.Items.OrderedAdd(resultItem, (a, b) => StringComparer.OrdinalIgnoreCase.Compare(a.CodeItem.DisplayName, b.CodeItem.DisplayName));
            }

            //Update test execution state
            if (e.Value.Method == _testExecuting)
            {
                _testExecuting = null;
            }
            UpdateTestExecutionState();
        }
Ejemplo n.º 2
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();
            }
        }