Пример #1
0
 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);
 }
Пример #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;
        }
Пример #3
0
 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);
 }
Пример #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);
        }
Пример #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);
        }
Пример #7
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;
        }
Пример #8
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;
        }
Пример #9
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;
        }
Пример #10
0
 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);
 }