示例#1
0
 private void StateChangedHandler(object sender, ParserStateEventArgs e)
 {
     if (!CanRun || e.IsError)
     {
         refreshBackoff = false;
     }
     // CanRun returned true already, only refresh tests if we're not backed off
     else if (!refreshBackoff && e.OldState != ParserState.Busy)
     {
         refreshBackoff = true;
         Tests          = TestDiscovery.GetAllTests(_state);
         _uiDispatcher.InvokeAsync(() => TestsRefreshed?.Invoke(this, EventArgs.Empty));
     }
 }
示例#2
0
        private void StateChangedHandler(object sender, ParserStateEventArgs e)
        {
            if (e.OldState == ParserState.Started)
            {
                _uiDispatcher.InvokeAsync(() => TestsRefreshStarted?.Invoke(this, EventArgs.Empty));
                return;
            }

            if (!CanRun || e.IsError)
            {
                _listening = true;
            }
            // CanRun returned true already, only refresh tests if we're not backed off
            else if (_listening && e.OldState != ParserState.Busy)
            {
                _listening = false;
                var updates = TestDiscovery.GetAllTests(_state).ToList();
                var run     = new List <TestMethod>();
                var known   = new Dictionary <TestMethod, TestOutcome>();

                foreach (var test in updates)
                {
                    var match = _lastRun.FirstOrDefault(ut => ut.Equals(test));
                    if (match != null)
                    {
                        run.Add(match);
                    }

                    if (_knownOutcomes.ContainsKey(test))
                    {
                        known.Add(test, _knownOutcomes[test]);
                    }
                }

                _tests         = updates;
                _lastRun       = run;
                _knownOutcomes = known;
                _uiDispatcher.InvokeAsync(() => TestsRefreshed?.Invoke(this, EventArgs.Empty));
            }
        }