Пример #1
0
        /// <summary>
        /// </summary>
        /// <param name = "changelessMutant"></param>
        /// <returns>true if session can continue</returns>
        private bool CheckForTestingErrors(Mutant changelessMutant)
        {
            if (changelessMutant.State == MutantResultState.Error &&
                !(changelessMutant.MutantTestSession.Exception is AssemblyVerificationException))
            {
                _svc.Logging.ShowError(UserMessages.ErrorPretest_UnknownError(
                                           changelessMutant.MutantTestSession.Exception.ToString()));

                return(false);
            }
            else if (changelessMutant.State == MutantResultState.Killed)
            {
                if (changelessMutant.KilledSubstate == MutantKilledSubstate.Cancelled)
                {
                    return(_svc.Logging.ShowYesNoQuestion(UserMessages.ErrorPretest_Cancelled()));
                }

                var testMethods = changelessMutant.TestRunContexts
                                  .SelectMany(c => c.TestResults.ResultMethods).ToList();

                var test = testMethods.FirstOrDefault(t => t.State == TestNodeState.Failure);

                var allFailedTests = testMethods
                                     .Where(t => t.State == TestNodeState.Failure || t.State == TestNodeState.Inconclusive)
                                     .Select(_ => _.Name)
                                     .ToList();

                string allFailedString = allFailedTests.Aggregate((a, b) => a + "\n" + b);


                string testName    = null;
                string testMessage = null;
                if (test != null)
                {
                    testName    = test.Name;
                    testMessage = test.Message;
                }
                else
                {
                    var testInconcl = testMethods
                                      .First(t => t.State == TestNodeState.Inconclusive);

                    testName    = testInconcl.Name;
                    testMessage = "Test was inconclusive.";
                }
                bool disableAndContinue = _svc.Logging.ShowYesNoQuestion(
                    UserMessages.ErrorPretest_TestsFailed(allFailedTests.Count.ToString(),
                                                          allFailedString, testName, testMessage));
                return(disableAndContinue);
                //return _svc.Logging.ShowYesNoQuestion(UserMessages.ErrorPretest_TestsFailed(testName, testMessage));
            }
            return(true);
        }