public void Constructs_root_element() // i.e. without any parent
 {
     var run = CreateFakeTestStepRun("123", true, TestOutcome.Passed);
     var node = new TestStepRunNode(run, null, 0);
     Assert.AreSame(run, node.Run);
     Assert.IsNull(node.Parent);
     Assert.AreEqual(0, node.Index);
     Assert.IsEmpty(node.Children);
     Assert.AreEqual(1, node.Count);
 }
Exemple #2
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="run">The test step run.</param>
        /// <param name="parent">The parent node.</param>
        /// <param name="index">The zero-based index of the test step run in the sequential representation of the tree.</param>
        public TestStepRunNode(TestStepRun run, TestStepRunNode parent, int index)
        {
            if (run == null)
            {
                throw new ArgumentNullException("run");
            }

            this.run    = run;
            this.parent = parent;
            this.index  = index;
        }
 public void Constructs_not_root_element()
 {
     var runParent = CreateFakeTestStepRun("123", false, TestOutcome.Passed);
     var parent = new TestStepRunNode(runParent, null, 0);
     var run = CreateFakeTestStepRun("456", true, TestOutcome.Passed);
     var node = new TestStepRunNode(run, parent, 1);
     Assert.AreSame(run, node.Run);
     Assert.AreSame(parent, node.Parent);
     Assert.AreEqual(1, node.Index);
     Assert.IsEmpty(node.Children);
     Assert.AreEqual(1, node.Count);
 }
Exemple #4
0
        /// <summary>
        /// Builds the tree under the specified root test step run.
        /// </summary>
        /// <param name="root">The root test step run.</param>
        /// <returns></returns>
        public static TestStepRunNode BuildTreeFromRoot(TestStepRun root)
        {
            if (root == null)
            {
                var step = new TestStepData(String.Empty, String.Empty, String.Empty, String.Empty);
                root        = new TestStepRun(step);
                root.Result = new TestResult();
            }

            int index = 0;
            var node  = new TestStepRunNode(root, null, index++);

            node.Children.AddRange(GetChildren(node, ref index));
            return(node);
        }
Exemple #5
0
        private static IList <TestStepRunNode> GetChildren(TestStepRunNode parent, ref int index)
        {
            var list = new List <TestStepRunNode>();

            foreach (TestStepRun run in parent.Run.Children)
            {
                var node = new TestStepRunNode(run, parent, index);

                if (node.Run.Children.Count == 0)
                {
                    index++;
                }

                node.Children.AddRange(GetChildren(node, ref index));
                list.Add(node);
            }

            return(list);
        }
        /// <inheritdoc />
        public VelocityContext CreateVelocityContext(IReportWriter reportWriter, FormatHelper helper)
        {
            var context = new VelocityContext();

            context.Put("report", reportWriter.Report);
            var root = reportWriter.Report.TestPackageRun == null ? null : reportWriter.Report.TestPackageRun.RootTestStepRun;

            context.Put("tree", TestStepRunNode.BuildTreeFromRoot(root));
            context.Put("helper", helper);
            context.Put("resourceRoot", reportWriter.ReportContainer.ReportName);
            context.Put("passed", TestStatus.Passed);
            context.Put("failed", TestStatus.Failed);
            context.Put("skipped", TestStatus.Skipped);
            context.Put("inconclusive", TestStatus.Inconclusive);
            context.Put("pagingEnabled", false);
            context.Put("pageIndex", 0);
            context.Put("pageSize", 0);
            context.Put("pageCount", 1);
            return(context);
        }
        private static IList<TestStepRunNode> GetChildren(TestStepRunNode parent, ref int index)
        {
            var list = new List<TestStepRunNode>();

            foreach (TestStepRun run in parent.Run.Children)
            {
                var node = new TestStepRunNode(run, parent, index);

                if (node.Run.Children.Count == 0)
                    index++;

                node.Children.AddRange(GetChildren(node, ref index));
                list.Add(node);
            }

            return list;
        }
        /// <summary>
        /// Builds the tree under the specified root test step run.
        /// </summary>
        /// <param name="root">The root test step run.</param>
        /// <returns></returns>
        public static TestStepRunNode BuildTreeFromRoot(TestStepRun root)
        {
            if (root == null)
            {
                var step = new TestStepData(String.Empty, String.Empty, String.Empty, String.Empty);
                root = new TestStepRun(step);
                root.Result = new TestResult();
            }

            int index = 0;
            var node = new TestStepRunNode(root, null, index++);
            node.Children.AddRange(GetChildren(node, ref index));
            return node;
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="run">The test step run.</param>
        /// <param name="parent">The parent node.</param>
        /// <param name="index">The zero-based index of the test step run in the sequential representation of the tree.</param>
        public TestStepRunNode(TestStepRun run, TestStepRunNode parent, int index)
        {
            if (run == null)
                throw new ArgumentNullException("run");

            this.run = run;
            this.parent = parent;
            this.index = index;
        }
 public void IsVisibleInPage(int index, int pageIndex, bool expectedVisible)
 {
     var run = CreateFakeTestStepRun("123", true, TestOutcome.Passed);
     var node = new TestStepRunNode(run, null, index);
     bool actualVisible = node.IsVisibleInPage(pageIndex, 1000);
     Assert.AreEqual(expectedVisible, actualVisible);
 }