Beispiel #1
0
        private static XElement CreateErrorElement(TestResultInfo result)
        {
            string errorMessage = result.ErrorMessage;

            int    indexOfErrorType = errorMessage.IndexOf('(');
            string errorType        = string.Empty;

            errorTypeKeyValuePair.TryGetValue(errorMessage.Substring(1, indexOfErrorType - 2), out errorType);
            errorMessage = errorMessage.Substring(indexOfErrorType + 1);

            int    indexOfName = errorMessage.IndexOf(')');
            string name        = errorMessage.Substring(0, indexOfName);

            errorMessage = errorMessage.Substring(indexOfName + 4);

            int    indexOfExceptionType = errorMessage.IndexOf(':');
            string exceptionType        = errorMessage.Substring(0, indexOfExceptionType - 1);

            XElement errorElement = new XElement("error");

            errorElement.SetAttributeValue("type", errorType);
            errorElement.SetAttributeValue("name", name);

            errorElement.Add(CreateFailureElement(exceptionType, errorMessage, result.ErrorStackTrace));

            return(errorElement);
        }
        private static XElement CreateTestCaseElement(TestResultInfo result)
        {
            var element = new XElement("testcase",
                                       new XAttribute("classname", result.Type),
                                       new XAttribute("name", result.Name),
                                       new XAttribute("time", result.Time.TotalSeconds.ToString("N7", CultureInfo.InvariantCulture)));

            if (result.Outcome == TestOutcome.Failed)
            {
                var failure = new XElement("error");
                if ((!(string.IsNullOrEmpty(result.ErrorMessage))) && (!(string.IsNullOrEmpty(result.ErrorStackTrace))))
                {
                    failure.Value = RemoveInvalidXmlChar(result.ErrorMessage) + System.Environment.NewLine + RemoveInvalidXmlChar(result.ErrorStackTrace);
                }
                else if (!(string.IsNullOrEmpty(result.ErrorMessage)))
                {
                    failure.Value = RemoveInvalidXmlChar(result.ErrorMessage);
                }
                else
                {
                    failure.Value = RemoveInvalidXmlChar(result.ErrorStackTrace);
                }
                element.Add(failure);
            }
            return(element);
        }
Beispiel #3
0
    private static XElement CreateTestElement(TestResultInfo result)
    {
        var element = new XElement("test",
                                   new XAttribute("name", result.Name),
                                   new XAttribute("type", result.Type),
                                   new XAttribute("method", result.Method),
                                   new XAttribute("time", result.Time.TotalSeconds.ToString("N7", CultureInfo.InvariantCulture)),
                                   new XAttribute("result", OutcomeToString(result.Outcome)));

        if (result.Outcome == TestOutcome.Failed)
        {
            element.Add(new XElement("failure",
                                     new XElement("message", result.ErrorMessage),
                                     new XElement("stack-trace", result.ErrorStackTrace)));
        }

        if (result.Traits != null)
        {
            element.Add(new XElement("traits",
                                     from trait in result.Traits
                                     select new XElement("trait", new XAttribute("name", trait.Name), new XAttribute("value", trait.Value))));
        }

        return(element);
    }
Beispiel #4
0
        public void GetHashCodeShouldReturnAnUniqueHash()
        {
            var result     = new TestResult(new TestCase());
            var resultInfo = new TestResultInfo(result, string.Empty, string.Empty, string.Empty);

            Assert.AreNotEqual(new TestResult(new TestCase()).GetHashCode(), resultInfo.GetHashCode());
        }
Beispiel #5
0
        private void ShowTestResults()
        {
            dataGridViewResults.Rows.Clear();

            int currentNumber = TestsList.CurrentCellAddress.Y;

            if (currentNumber < 0)
            {
                return;
            }

            int            id             = Convert.ToInt32(TestsList.Rows[currentNumber].Cells[0].Value);
            TestResultInfo testResultInfo = _testResultEngine.GetTestResultById(id);

            AnxietyResults anxietyResults = _anxietyTestResultMaker.MakeResults(testResultInfo.Result);

            dataGridViewResults.Rows.Add(new object[] { "ОБЩАЯ ТРЕВОЖНОСТЬ", anxietyResults.GeneralAnxiety });
            dataGridViewResults.Rows.Add(new object[] { "Общая тревожность в школе", anxietyResults.GeneralAnxietyForScool });
            dataGridViewResults.Rows.Add(new object[] { "Переживание социального стресса", anxietyResults.ExperienceOfSocialStress });
            dataGridViewResults.Rows.Add(new object[] { "Фрустрация потребности в достижение успеха", anxietyResults.FrustrationNeedForSuccess });
            dataGridViewResults.Rows.Add(new object[] { "Страх самовыражения", anxietyResults.FearOfExpression });
            dataGridViewResults.Rows.Add(new object[] { "Страх ситуации проверки знаний", anxietyResults.FearSituationKnowledgeTest });
            dataGridViewResults.Rows.Add(new object[] { "Страх не соответствовать ожиданиям окружающих", anxietyResults.FearDoesNotMeetTheExpectationsOfOthers });
            dataGridViewResults.Rows.Add(new object[] { "Низкая физиологическая сопротивляемость стрессу", anxietyResults.LowPhysiologicalResistanceToStress });
            dataGridViewResults.Rows.Add(new object[] { "Проблемы и страхи в отношениях с учителями", anxietyResults.ProblemsAndFearsInRelationshipWithTeachers });

            _originalNote        = testResultInfo.Note;
            richTextBoxNote.Text = testResultInfo.Note;
        }
Beispiel #6
0
        public void EqualsShouldReturnFalseForNonTestResultInfoObject()
        {
            var result     = new TestResult(new TestCase());
            var resultInfo = new TestResultInfo(result, string.Empty, string.Empty, string.Empty);

            Assert.IsFalse(resultInfo.Equals(new ()));
        }
Beispiel #7
0
        private void AddNewInfos(string path, DateTime passingTime)
        {
            string testName = GetLastPathPart(path);

            foreach (string classFolderPath in Directory.GetDirectories(path))
            {
                string className = GetLastPathPart(classFolderPath);

                foreach (string pupilFilePath in Directory.GetFiles(classFolderPath, "*.txt"))
                {
                    string pupilFileName = GetLastPathPart(pupilFilePath);

                    int    spaceIndex = pupilFileName.IndexOf(' ');
                    int    pointIndex = pupilFileName.IndexOf('.');
                    string lastName   = pupilFileName.Substring(0, spaceIndex);
                    string firstName  = pupilFileName.Substring(spaceIndex + 1, pointIndex - spaceIndex - 1);
                    string result     = File.ReadAllText(pupilFilePath);

                    int            classId        = _classEngine.GetClassId(className);
                    int            pupilId        = _pupilEngine.GetPupilId(firstName, lastName);
                    var            classInfo      = new ClassInfo(classId, className, string.Empty);
                    var            pupilInfo      = new PupilInfo(pupilId, firstName, lastName, classId);
                    AnxietyResults anxietyResults = _anxietyTestResultMaker.MakeResults(result);
                    var            testResultInfo = new TestResultInfo(_testResultEngine.GetNextTestResultId(), testName, pupilId, result, passingTime, _anxietyTestResultMaker.DoesHighAnxietyExist(anxietyResults), classId, string.Empty);

                    _classEngine.AddClassInfoSorted(classInfo);
                    _pupilEngine.AddPupilInfoSorted(pupilInfo);
                    _testResultEngine.AddTestResultInfoSorted(testResultInfo);
                }
            }
        }
        private bool TestFailed(TestResultInfo testResult, string name, string message)
        {
            var result = testResult.Name == name && testResult.Result.ToString() == "FAILED";

            result = result && message == testResult.Message;
            return(result);
        }
        public void AddTestResultInfoSorted(TestResultInfo testResultInfo)
        {
            var sortedTestResultInfo = new List <TestResultInfo>();

            int index = TestResultInfos.Count;

            for (int i = 0; i < TestResultInfos.Count; i++)
            {
                if (DateTime.Compare(testResultInfo.PassingDate, TestResultInfos[i].PassingDate) < 0)
                {
                    index = i;
                    break;
                }
            }

            for (int i = 0; i < index; i++)
            {
                sortedTestResultInfo.Add(TestResultInfos[i]);
            }

            sortedTestResultInfo.Add(testResultInfo);

            for (int i = index; i < TestResultInfos.Count; i++)
            {
                sortedTestResultInfo.Add(TestResultInfos[i]);
            }

            TestResultInfos = sortedTestResultInfo;
        }
Beispiel #10
0
        private void LogNewTestResults(List <TestResultInfo> newTestResults, ref TestProjectExecutionResult testResultContext)
        {
            List <TestResultInfo> InnerResults = new List <TestResultInfo>();

            foreach (TestResultInfo resultInfo in newTestResults)
            {
                if (resultInfo.ParentExecId.Equals(default(Guid)))
                {
                    testResultContext.TestResults.Add(resultInfo);
                }
                else
                {
                    InnerResults.Add(resultInfo);
                }

                BroadCastMessage($"{resultInfo.DisplayName}执行完成,执行结果:{resultInfo.Outcome.ToString()}");
            }

            foreach (TestResultInfo resultInfo in InnerResults)
            {
                TestResultInfo tmp = testResultContext.TestResults.First(o => o.ExecutionId.Equals(resultInfo.ParentExecId));
                if (tmp != null)
                {
                    if (tmp.InnerResults == null)
                    {
                        tmp.InnerResults = new List <TestResultInfo>();
                    }

                    tmp.InnerResults.Add(resultInfo);
                }
            }
        }
Beispiel #11
0
 private void SaveResultsToJson(TestResultInfo testResultInfo)
 {
     using (StreamWriter file = File.CreateText(GetSaveFilePath(string.Format("{0}-{1:yyyyMMdd_HHmmss}.json", testResultInfo.TestName, DateTime.Now))))
     {
         JsonSerializer serializer = new JsonSerializer();
         serializer.Serialize(file, testResultInfo);
     }
 }
Beispiel #12
0
 private Test CreateTest(TestResultInfo result)
 {
     return(new ()
     {
         Name = result.Method,
         Result = result.Outcome.ToString()
     });
 }
Beispiel #13
0
        private async void SetTestMethodAsync(TestCaseInfo testMethodInfo)
        {
            if (testMethodInfo != null)
            {
                TestResultInfo info = await this.testResultsRepository.GetTestResultAsync(testMethodInfo.DisplayName);

                this.CurrentTestMethodResult = info;
            }
        }
Beispiel #14
0
 IDictionary <string, TestResultInfo> GetResultInfos(string runId)
 {
     return(results.GetResults(runId)
            .ToDictionary(entry => entry.Key, delegate(KeyValuePair <string, TestResult> entry) {
         var retVal = new TestResultInfo();
         retVal.Result = entry.Value;
         retVal.Artifacts = results.GetArtifacts(runId, entry.Key);
         return retVal;
     }));
 }
Beispiel #15
0
        public void EqualsShouldReturnTrueIfErrorMessageAndStackTraceMatch()
        {
            var result = new TestResult(new TestCase());
            var r1     = new TestResultInfo(result, string.Empty, string.Empty, string.Empty);
            var r2     = new TestResultInfo(result, "ns", "type", "method");

            Assert.IsFalse(r1 == r2);
            Assert.IsTrue(Equals(r1, r2));
            Assert.IsTrue(r1.Equals(r2));
        }
Beispiel #16
0
        public bool DoesPupilHasHighAnxiety(int pupilId)
        {
            TestResultInfo testResultInfo = TestResultInfos.FirstOrDefault(x => x.PupilId == pupilId && x.Name == "Test_Phillipsa");

            if (testResultInfo == null)
            {
                return(false);
            }

            return(testResultInfo.HasHighAnxietys);
        }
Beispiel #17
0
        public XmlTestResult(TestResultInfo testResultInfo)
        {
            switch (testResultInfo.Result)
            {
            case TestResultInfo.TestResults.Passed: this.Status = Results.Passed; break;

            case TestResultInfo.TestResults.Failed: this.Status = Results.Failed; break;

            case TestResultInfo.TestResults.UnexpectedError: this.Status = Results.UnexpectedError; break;
            }
        }
Beispiel #18
0
 private Test CreateTest(TestResultInfo result)
 {
     return(new ()
     {
         FullyQualifiedName = result.TestCase.FullyQualifiedName,
         DisplayName = result.TestCase.DisplayName,
         Namespace = result.Namespace,
         Type = result.Type,
         Method = result.Method,
         Result = result.Outcome.ToString(),
     });
 }
Beispiel #19
0
        static TestRunInfo ProcessTestRunInfo(TestRunInfo tri)
        {
            var tri2 = new TestRunInfo(tri);

            tri2.Results = tri.Results
                           .ToDictionary(a => a.Key, delegate(KeyValuePair <string, TestResultInfo> entry) {
                var replacement       = new TestResultInfo(entry.Value);
                replacement.Artifacts = entry.Value.Artifacts
                                        .Select((ai, i) => ProcessArtifactInfo(tri.Id, entry.Key, i, ai)).ToArray();;
                return(replacement);
            });
            return(tri2);
        }
            public override bool Equals(object obj)
            {
                if (obj is TestResultInfo)
                {
                    TestResultInfo objectToCompare = (TestResultInfo)obj;
                    if (string.Compare(this.ErrorMessage, objectToCompare.ErrorMessage) == 0 && string.Compare(this.ErrorStackTrace, objectToCompare.ErrorStackTrace) == 0)
                    {
                        return(true);
                    }
                }

                return(false);
            }
Beispiel #21
0
        public void RemoveById(int id)
        {
            TestResultInfo testResultInfo = TestResultInfos.FirstOrDefault(x => x.Id == id);

            if (testResultInfo == null)
            {
                MessageBox.Show(string.Format("Внутренняя ошибка программы: результат теста с id={0} не найден. Удаление невозможно.", id), "Критическая ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            TestResultInfos.Remove(testResultInfo);

            SaveTestResults();
        }
Beispiel #22
0
        public void UpdateNote(int id, string newNote)
        {
            TestResultInfo testResultInfo = TestResultInfos.FirstOrDefault(x => x.Id == id);

            if (testResultInfo == null)
            {
                MessageBox.Show(string.Format("Внутренняя ошибка программы: результат теста с id={0} не найден. Изменение поля невозможно.", id), "Критическая ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            testResultInfo.Note = newNote;

            SaveTestResults();
        }
Beispiel #23
0
        public void EqualsShouldReturnFalseIfErrorMessageOrStackTraceDoNotMatch()
        {
            var result1 = new TestResult(new TestCase())
            {
                ErrorMessage = "error 1"
            };
            var result2 = new TestResult(new TestCase())
            {
                ErrorMessage = "error 2"
            };
            var r1 = new TestResultInfo(result1, string.Empty, string.Empty, string.Empty);
            var r2 = new TestResultInfo(result2, string.Empty, string.Empty, string.Empty);

            Assert.IsFalse(r1.Equals(r2));
        }
Beispiel #24
0
        private static XElement CreateTestElement(TestResultInfo result)
        {
            var element = new XElement("test",
                                       new XAttribute("name", result.Name),
                                       new XAttribute("type", result.Type),
                                       new XAttribute("method", result.Method),
                                       new XAttribute("time", result.Time.TotalSeconds.ToString("N7", CultureInfo.InvariantCulture)),
                                       new XAttribute("result", OutcomeToString(result.Outcome)));

            StringBuilder stdOut = new StringBuilder();

            foreach (var m in result.Messages)
            {
                if (TestResultMessage.StandardOutCategory.Equals(m.Category, StringComparison.OrdinalIgnoreCase))
                {
                    stdOut.AppendLine(m.Text);
                }
            }

            if (!string.IsNullOrWhiteSpace(stdOut.ToString()))
            {
                element.Add(new XElement("output", RemoveInvalidXmlChar(stdOut.ToString())));
            }

            var fileName = result.TestCase.CodeFilePath;

            if (!string.IsNullOrWhiteSpace(fileName))
            {
                element.Add(new XElement("source-file", fileName));
                element.Add(new XElement("source-line", result.TestCase.LineNumber));
            }

            if (result.Outcome == TestOutcome.Failed)
            {
                element.Add(new XElement("failure",
                                         new XElement("message", RemoveInvalidXmlChar(result.ErrorMessage)),
                                         new XElement("stack-trace", RemoveInvalidXmlChar(result.ErrorStackTrace))));
            }

            if (result.Traits != null)
            {
                element.Add(new XElement("traits",
                                         from trait in result.Traits
                                         select new XElement("trait", new XAttribute("name", trait.Name), new XAttribute("value", trait.Value))));
            }

            return(element);
        }
Beispiel #25
0
        public TestResultInfo Run(RunTestSubOptions options)
        {
            if (!Directory.Exists(GetSaveFilePath()))
            {
                Directory.CreateDirectory(GetSaveFilePath());
            }

            var res = new TestResultInfo()
            {
                TestName          = Name,
                TestActionResults = RunImplementation(options)
            };

            SaveResultsToJson(res);
            return(res);
        }
        private static bool IsError(TestResultInfo result)
        {
            string errorMessage = result.ErrorMessage;

            if (!string.IsNullOrWhiteSpace(errorMessage))
            {
                foreach (var m in JUnitXmlTestLogger.errorTypes)
                {
                    if (errorMessage.IndexOf(m) >= 0)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Beispiel #27
0
        public object ResTestResultSetData(TestResultInfo testResultInfo)
        {
            string token = Request.Headers.Authorization.ToString();
            int    valid = new ExceptionHandler().TokenCheck(token);

            if (valid == 0)
            {
                return("Token has expired");
            }
            if (valid == -1)
            {
                return("Token has invalid signature");
            }
            int ret = repository.ResTestResultSetData(pclsCache, testResultInfo.TestId, testResultInfo.ObjectNo, testResultInfo.ObjCompany, testResultInfo.ObjIncuSeq, testResultInfo.TestType, testResultInfo.TestStand, testResultInfo.TestEquip, testResultInfo.TestEquip2, testResultInfo.Description, testResultInfo.ProcessStart, testResultInfo.ProcessEnd, testResultInfo.CollectStart, testResultInfo.CollectEnd, testResultInfo.TestTime, testResultInfo.TestResult, testResultInfo.TestPeople, testResultInfo.TestPeople2, testResultInfo.ReStatus, testResultInfo.RePeople, testResultInfo.ReTime, testResultInfo.TerminalIP, testResultInfo.TerminalName, testResultInfo.revUserId, testResultInfo.FormerStep, testResultInfo.NowStep, testResultInfo.LaterStep);

            return(new ExceptionHandler().SetData(Request, ret));
        }
        private static XElement CreateTestCaseElement(TestResultInfo result)
        {
            var element = new XElement("testcase",
                                       new XAttribute("classname", result.Type),
                                       new XAttribute("name", result.Method),
                                       new XAttribute("time", result.Time.TotalSeconds.ToString("N7", CultureInfo.InvariantCulture)));

            if (result.Outcome == TestOutcome.Failed)
            {
                var failure = new XElement("error");
                failure.SetAttributeValue("message", RemoveInvalidXmlChar(result.ErrorMessage));
                failure.Value = RemoveInvalidXmlChar(result.ErrorStackTrace);

                element.Add(failure);
            }

            return(element);
        }
Beispiel #29
0
        public TestResultsDisplay(IEnumerable <ModelTestResult> modelTestResults)
        {
            var    anyHelix         = false;
            string?gitHubRepository = null;
            var    emptyDictionary  = new Dictionary <string, string>();

            foreach (var modelTestResult in modelTestResults)
            {
                anyHelix = anyHelix || modelTestResult.IsHelixTestResult;
                gitHubRepository ??= modelTestResult.ModelBuild.GitHubRepository;

                var routeData = new Dictionary <string, string>();
                if (BuildsRequest is object)
                {
                    routeData["bq"] = BuildsRequest.GetQueryString();
                }

                var request = new SearchTestsRequest()
                {
                    Name = modelTestResult.TestFullName
                };

                routeData["tq"] = request.GetQueryString();

                var testResultInfo = new TestResultInfo()
                {
                    BuildNumber           = modelTestResult.ModelBuild.BuildNumber,
                    BuildUri              = DevOpsUtil.GetBuildUri(modelTestResult.ModelBuild.AzureOrganization, modelTestResult.ModelBuild.AzureProject, modelTestResult.ModelBuild.BuildNumber),
                    Kind                  = modelTestResult.ModelBuild.GetModelBuildKind().GetDisplayString(),
                    TestRun               = modelTestResult.ModelTestRun.Name,
                    TestFullName          = modelTestResult.TestFullName,
                    TestFullNameRouteData = routeData,
                    ErrorMessage          = modelTestResult.ErrorMessage,
                    HelixConsoleUri       = modelTestResult.HelixConsoleUri,
                    HelixRunClientUri     = modelTestResult.HelixRunClientUri,
                    HelixCoreDumpUri      = modelTestResult.HelixCoreDumpUri,
                    HelixTestResultsUri   = modelTestResult.HelixTestResultsUri,
                };
                Results.Add(testResultInfo);
            }

            IncludeHelixColumns = anyHelix;
            GitHubRepository    = gitHubRepository;
        }
Beispiel #30
0
        public void LoadTestResults()
        {
            TestResultInfos = new List <TestResultInfo>();
            if (!File.Exists(_testResultsDbPath))
            {
                return;
            }

            string content = File.ReadAllText(_testResultsDbPath);

            string[] parameters = content.Split(new[] { DatabaseEngine.RecordSeparator }, StringSplitOptions.RemoveEmptyEntries);

            foreach (string parameter in parameters)
            {
                string[] values        = parameter.Split(new[] { DatabaseEngine.ValueSeparator }, StringSplitOptions.None);
                var      testResulInfo = new TestResultInfo(values);
                TestResultInfos.Add(testResulInfo);
            }
        }