Exemple #1
0
        private void ReadUserStory(TestCaseRun testCaseRun, XmlReader xmlReader)
        {
            xmlReader.Read();

            while (xmlReader.NodeType != XmlNodeType.EndElement)
            {
                switch (xmlReader.Name)
                {
                case "userStory":
                    testCaseRun.AddUserStory(xmlReader.ReadElementContentAsString());
                    break;

                default:
                {
                    throw new NotSupportedException(
                              string.Format(
                                  CultureInfo.InvariantCulture,
                                  "Not supported xml node type. Node type = {0}",
                                  xmlReader.NodeType));
                }
                }
            }

            xmlReader.Read();
        }
Exemple #2
0
        private void ReadAttachments(TestCaseRun testCaseRun, XmlReader xmlReader)
        {
            xmlReader.Read();

            while (xmlReader.NodeType != XmlNodeType.EndElement)
            {
                switch (xmlReader.Name)
                {
                case "attachment":
                    string     attachmentName               = ReadAttribute(xmlReader, "name");
                    string     attachmentContentType        = ReadAttribute(xmlReader, "contentType");
                    string     attachmentPath               = ReadAttribute(xmlReader, "contentPath");
                    string     attachmentContentDisposition = ReadAttribute(xmlReader, "contentDisposition");
                    string     content    = xmlReader.ReadElementContentAsString();
                    Attachment attachment = new Attachment(attachmentName, attachmentContentType, attachmentPath, attachmentContentDisposition, content);
                    testCaseRun.AddAttachment(attachment);
                    break;

                default:
                {
                    throw new NotSupportedException(
                              string.Format(
                                  CultureInfo.InvariantCulture,
                                  "Not supported xml node type. Node type = {0} [{1}]",
                                  xmlReader.NodeType,
                                  xmlReader.Name));
                }
                }
            }

            xmlReader.Read();
        }
Exemple #3
0
        private void ReadTestCaseRun(TestCaseRun testCaseRun, XmlReader xmlReader)
        {
            string durationString = xmlReader.GetAttribute("duration");

            if (false == String.IsNullOrEmpty(durationString))
            {
                testCaseRun.Duration = TimeSpan.FromSeconds(double.Parse(durationString, CultureInfo.InvariantCulture));
            }

            xmlReader.Read();

            while (xmlReader.NodeType != XmlNodeType.EndElement)
            {
                switch (xmlReader.Name)
                {
                case "userStories":

                    ReadUserStory(testCaseRun, xmlReader);
                    break;

                case "message":
                case "error":     // obsolete
                    ReadMessage(testCaseRun, xmlReader);
                    break;

                case "attachments":
                    ReadAttachments(testCaseRun, xmlReader);
                    break;

                default:
                {
                    throw new NotSupportedException(
                              string.Format(
                                  CultureInfo.InvariantCulture,
                                  "Not supported xml node type. Node type = {0} [{1}]",
                                  xmlReader.NodeType,
                                  xmlReader.Name));
                }
                }
            }

            xmlReader.Read();
        }
 public void AddTestCaseRun(TestCaseRun testCaseRun)
 {
     testCasesRuns.Add(testCaseRun.TestCaseId, testCaseRun);
 }
Exemple #5
0
 private void ReadMessage(TestCaseRun testCaseRun, XmlReader xmlReader)
 {
     testCaseRun.Message = xmlReader.ReadElementContentAsString();
 }
Exemple #6
0
        private void ReadTestCaseRuns(TestSuiteRun testSuiteRun, XmlReader xmlReader)
        {
            if (xmlReader.IsEmptyElement)
            {
                xmlReader.Skip();
                return;
            }

            xmlReader.Read();

            while (xmlReader.NodeType != XmlNodeType.EndElement)
            {
                switch (xmlReader.Name)
                {
                case "case":
                    string gallioStatus        = ReadAttribute(xmlReader, "status");
                    TestExecutionStatus status = TestExecutionStatus.NotImplemented;

                    switch (gallioStatus)
                    {
                    case "passed":
                        status = TestExecutionStatus.Successful;
                        break;

                    case "failed":
                        status = TestExecutionStatus.Failed;
                        break;

                    case "pending":
                    case "skipped":
                    case "inconclusive":
                        status = TestExecutionStatus.NotImplemented;
                        break;

                    default:
                        throw new NotSupportedException(String.Format(CultureInfo.InvariantCulture, "Gallio test status '{0}' not supported", gallioStatus));
                    }

                    TestCaseRun testCaseRun = new TestCaseRun(
                        ReadAttribute(xmlReader, "id"),
                        status);

                    ReadTestCaseRun(testCaseRun, xmlReader);

                    testSuiteRun.AddTestCaseRun(testCaseRun);

                    break;

                default:
                {
                    throw new NotSupportedException(
                              string.Format(
                                  CultureInfo.InvariantCulture,
                                  "Unsupported xml node '{0}'",
                                  xmlReader.Name));
                }
                }
            }

            xmlReader.Read();
        }