Ejemplo n.º 1
1
        private void MakeHeaders(IXLWorksheet sheet, TestSuite suite)
        {
            int column = 1;

            for (; column <= deep; column++)
            {
                string header = string.Empty;

                for (int i = 1; i < column; i++)
                    header += "Sub-";

                sheet.Cell(row, column).Value = header + "Category";
                sheet.Column(column).Width = 20.86;
            }

            sheet.Cell(row, deep + 1).Value = "Name";
            sheet.Column(deep + 1).Width = 30;
            sheet.Cell(row, deep + 2).Value = "Id";
            sheet.Column(deep + 2).Width = 13;
            sheet.Cell(row, deep + 3).Value = "Summary";
            sheet.Column(deep + 3).Width = 42;
            sheet.Cell(row, deep + 4).Value = "Preconditions";
            sheet.Column(deep + 4).Width = 56.43;
            sheet.Cell(row, deep + 5).Value = "Actions";
            sheet.Column(deep + 5).Width = 100;
            sheet.Cell(row, deep + 6).Value = "Expected Results";
            sheet.Column(deep + 6).Width = 100;
            row++;
        }
 /// <summary>
 /// Show given suite on suite form and make form visible.
 /// </summary>
 /// <param name="suite"></param>
 public void DisplaySuite(TestSuite suite)
 {
     this.Tag = suite;
     this.txtTestSuiteName.Text = suite.Name;
     this.txtTestSuiteSummary.Text = suite.Description;
     this.Visible = true;
 }
Ejemplo n.º 3
0
        public XMLSuite(TestSuite testSuite)
        {
            this.suite = new XmlDocument();

            XmlNode n = this.WriteSuite(testSuite);
            this.suite.AppendChild(n);
        }
Ejemplo n.º 4
0
        internal void GenerateSuiteSheet(TestSuite suite)
        {
            IXLWorksheet sheet = workbook.AddWorksheet(suite.Name);

            sheet.Columns("A:Z").Style.Alignment.WrapText = true;
            sheet.Columns("A:Z").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
            sheet.Columns("A:Z").Style.Alignment.Vertical = XLAlignmentVerticalValues.Top;
            deep = suite.GetSuitsDeep();
            row = 1;
            MakeHeaders(sheet, suite);
            WriteSuite(sheet, suite, new List<string>());
        }
Ejemplo n.º 5
0
 public void AddSuite(TestSuite suite)
 {
     var xmlelem = WriteSuite(suite);
     this.root.AppendChild(xmlelem);
 }
Ejemplo n.º 6
0
        private XmlNode WriteSuite(TestSuite suite)
        {
            XmlElement node = this.suite.CreateElement("", "testsuite", "");
            node.SetAttribute("name", suite.Name);

            foreach (TestCase tc in suite.Tcs)
                node.AppendChild(WriteTC(tc));

            foreach (TestSuite s in suite.UnderSuits)
                node.AppendChild(WriteSuite(s));

            return node;
        }
Ejemplo n.º 7
0
        private TestSuite AddSuite(XmlNode node)
        {
            string name = node.Attributes.Count > 0 && node.Attributes[0].InnerText != null && node.Attributes[0].InnerText != string.Empty ? node.Attributes[0].InnerText : "<<Test Suite>>";
            TestSuite suite = new TestSuite(name, string.Empty);

            foreach (XmlNode n in node.ChildNodes)
            {
                if (n.Name == "testsuite")
                    suite.UnderSuits.Add(AddSuite(n));
                else if (n.Name == "testcase")
                    suite.AddTestCase(AddCase(n));
                else if (n.Name == "details")
                    suite.Description = n.Value;
            }

            return suite;
        }
Ejemplo n.º 8
0
        private void WriteSuite(IXLWorksheet sheet, TestSuite suite, List<string> oldCats)
        {
            List<string> cats = oldCats;

            if (suite.Tcs.Count > 0)
                WriteSuiteTcs(sheet, suite, oldCats);

            if (suite.UnderSuits.Count > 0)
            {
                cats.Add(suite.Name);

                foreach (TestSuite s in suite.UnderSuits)
                    WriteSuite(sheet, s, new List<string>(cats));
            }
        }
Ejemplo n.º 9
0
        private void WriteSuiteTcs(IXLWorksheet sheet, TestSuite suite, List<string> cats)
        {
            foreach (TestCase testCase in suite.Tcs)
            {
                for (int column = 1; column <= cats.Count; column++)
                    sheet.Cell(row, column).Value = cats[column - 1];

                sheet.Cell(row, cats.Count + 1).Value = suite.Name;
                sheet.Cell(row, deep + 1).Value = testCase.Name;
                sheet.Cell(row, deep + 2).Value = testCase.Id;
                sheet.Cell(row, deep + 3).Value = testCase.Summary;
                sheet.Cell(row, deep + 4).Value = testCase.Preconditions;
                string actions = string.Empty;
                string expected = string.Empty;

                if (testCase.Steps.Count == 1)
                {
                    actions += testCase.Steps[0].Action;
                    expected += testCase.Steps[0].ExpectedResult;
                }
                else
                {
                    foreach (Step step in testCase.Steps)
                    {
                        actions += step.StepNumber.ToString() + ". " + step.Action + "\n";
                        expected += step.StepNumber.ToString() + ". " + step.ExpectedResult + "\n";
                    }
                }

                sheet.Cell(row, deep + 5).Value = actions.Substring(0, actions.Length - 1);
                sheet.Cell(row, deep + 6).Value = expected.Substring(0, expected.Length - 1);
                row++;
            }
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Generating tree node based on TestSuite object.
 /// </summary>
 /// <param name="suite"></param>
 public void GenerateTreeNode(TestSuite suite)
 {
     this.suiteTreeView.BeginUpdate();
     this.suiteTreeView.Nodes.Add(this.MakeSuiteTree(suite));
     this.suiteTreeView.EndUpdate();
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Update given suite node Text to equals with suite Name.
        /// </summary>
        /// <param name="suite"></param>
        /// <param name="nodes"></param>
        private void UpdateTreeViewSuiteNames(TestSuite suite, TreeNodeCollection nodes)
        {
            foreach (TreeNode node in nodes)
            {
                TestSuite suiteTag = node.Tag as TestSuite;

                if (suiteTag != null && suiteTag.Equals(suite))
                {
                    this.suiteTreeView.BeginUpdate();
                    node.Text =  (node.Tag as TestSuite).VisibleName;
                    this.suiteTreeView.EndUpdate();
                }
                else if (node.Nodes.Count > 0)
                {
                    this.UpdateTreeViewSuiteNames(suite, node.Nodes);
                }
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Make TreeNode from given suite and place suite ref into node Tag.
        /// </summary>
        /// <param name="suite"></param>
        /// <returns></returns>
        private TreeNode MakeSuiteTree(TestSuite suite)
        {
            TreeNode node = new TreeNode();
            node.Text = suite.VisibleName;
            node.Tag = suite;
            suite.PropertyChanged += new PropertyChangedEventHandler(Suite_PropertyChanged);

            foreach (TestSuite s in suite.UnderSuits)
            {
                node.Nodes.Add(MakeSuiteTree(s));
            }

            foreach (TestCase testCase in suite.Tcs)
            {
                testCase.PropertyChanged += new PropertyChangedEventHandler(TestCase_PropertyChanged);
                TreeNode tcNode = new TreeNode();
                tcNode.Text = testCase.Name;
                tcNode.Tag = testCase;
                tcNode.ImageIndex = 1;
                tcNode.SelectedImageIndex = 0;
                node.Nodes.Add(tcNode);
            }

            return node;
        }
Ejemplo n.º 13
0
        private TestSuite MakeSuite(TreeNode node)
        {
            TestSuite suite = new TestSuite((node.Tag as TestSuite).Name, (node.Tag as TestSuite).Description);

            foreach (TreeNode n in node.Nodes)
            {
                if (n.Nodes.Count > 0 && n.Checked == true)
                    suite.UnderSuits.Add(MakeSuite(n));
                else if (n.Checked == true && (n.Tag as TestCase) != null)
                    suite.Tcs.Add(n.Tag as TestCase);
            }

            return suite;
        }
Ejemplo n.º 14
0
        private TestSuite CloneSuite(TreeNode testSuite)
        {
            TestSuite originalSuite = testSuite.Tag as TestSuite;
            TestSuite clonedSuite = new TestSuite(originalSuite.Name, originalSuite.Description);

            clonedSuite.UnderSuits = new List<TestSuite>();
            clonedSuite.Tcs = new List<TestCase>();

            if (testSuite.Nodes != null)
            {
                foreach (TreeNode node in testSuite.Nodes)
                {
                    if (node.Tag is TestCase)
                        node.Tag = this.CloneCase(node);
                    else if (this.copiedNode.Tag is TestSuite)
                        node.Tag = this.CloneSuite(node);
                }
            }

            clonedSuite.PropertyChanged += new PropertyChangedEventHandler(Suite_PropertyChanged);

            return clonedSuite;
        }