Exemplo n.º 1
0
 internal override TestInvoker CreateInvoker(TestPath path, TestInvoker invoker)
 {
     if ((Flags & TestFlags.Browsable) != 0)
     {
         invoker = new ResultGroupTestInvoker(path, invoker);
     }
     return(new ParameterizedTestInvoker(this, path, invoker));
 }
Exemplo n.º 2
0
 public ParameterSourceInstance(
     ParameterSourceHost <T> host, TestPath path, TestInstance parent,
     ITestParameterSource <T> sourceInstance, string filter)
     : base(host, path, parent)
 {
     SourceInstance = sourceInstance;
     Filter         = filter;
 }
Exemplo n.º 3
0
        internal override TestInvoker CreateInvoker(TestPath path, TestInvoker invoker)
        {
            invoker = CreateResultGroup(path, invoker);

            invoker = new TestBuilderInvoker(this, path, invoker);

            return(invoker);
        }
Exemplo n.º 4
0
 protected ParameterizedTestHost(string name, TypeInfo type,
                                 IParameterSerializer serializer, TestFlags flags = TestFlags.None)
     : base(TestPathType.Parameter, name, name,
            TestPath.GetFriendlyName(type.AsType()), flags)
 {
     ParameterName     = name;
     ParameterTypeInfo = type;
     Serializer        = serializer;
 }
Exemplo n.º 5
0
        internal TestPath(TestHost host, TestPath parent, ITestParameter parameter = null)
        {
            Host   = host;
            Flags  = host.Flags;
            Parent = parent;

            this.parameter = host.HasFixedParameter ? host.GetFixedParameter() : parameter;
            this.name      = GetTestName(host, parent, this.parameter);
        }
Exemplo n.º 6
0
        public TestPath GetCurrentPath()
        {
            if (currentPath != null)
            {
                return(currentPath);
            }

            var node = new TestNodeInternal(Instance.Host, Parameter);

            currentPath = new TestPath(Instance.ParentPath, node);
            return(currentPath);
        }
Exemplo n.º 7
0
        internal TestInstance CreateInstance(TestContext ctx, TestPath path, TestInstance parent)
        {
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }

            var instance = CreateInstance(path, parent);

            instance.Initialize(ctx);
            return(instance);
        }
Exemplo n.º 8
0
        internal static XElement SerializePath(TestPath path)
        {
            var node = new XElement(PathName);

            while (path != null)
            {
                var element = WritePathNode(path.Host, path.Parameter);
                node.AddFirst(element);
                path = path.Parent;
            }

            return(node);
        }
Exemplo n.º 9
0
        TestInvoker CreateResultGroup(TestPath path, TestInvoker invoker)
        {
            if (TestName.IsNullOrEmpty(Builder.TestName))
            {
                return(invoker);
            }
            if ((path.Flags & (TestFlags.Hidden | TestFlags.FlattenHierarchy)) != 0)
            {
                return(invoker);
            }

            return(new ResultGroupTestInvoker(path, invoker));
        }
Exemplo n.º 10
0
        TestPath GetCurrentPath()
        {
            TestPath parentPath = null;

            if (Parent != null)
            {
                parentPath = Parent.GetCurrentPath();
            }

            var parameter = GetCurrentParameter();

            return(new TestPath(Path.Host, parentPath, parameter));
        }
Exemplo n.º 11
0
        public virtual T GetParameter <T> ()
        {
            var parameter = GetCurrentParameter();

            if (parameter == null)
            {
                throw new InternalErrorException();
            }

            var path = new TestPath(Parent.Host, Parent.Path, parameter);

            return(path.GetParameter <T> ());
        }
Exemplo n.º 12
0
        protected TestInstance(TestHost host, TestPath path, TestInstance parent)
        {
            if (host == null)
            {
                throw new ArgumentNullException("host");
            }
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }

            Host   = host;
            Parent = parent;
            Path   = path;
        }
Exemplo n.º 13
0
        internal static TestPathTreeNode DeserializePath(TestSuite suite, TestContext ctx, XElement root)
        {
            var resolver = (IPathResolver)suite;

            var path = TestPath.Read(root);

            foreach (var node in path.Nodes)
            {
                if (node.PathType == TestPathType.Group)
                {
                    continue;
                }
                resolver = resolver.Resolve(ctx, node);
            }

            return(resolver.Node);
        }
Exemplo n.º 14
0
        TestInvoker WalkHierarchy(TestInvoker invoker, TestPath root, bool flattenHierarchy)
        {
            var node = Path.Parent;

            while (node != root)
            {
                var cloned = node.Clone();
                if (flattenHierarchy)
                {
                    cloned.Flags |= TestFlags.FlattenHierarchy;
                }
                invoker = node.Host.CreateInvoker(cloned, invoker);
                node    = node.Parent;
            }

            return(invoker);
        }
Exemplo n.º 15
0
        protected TestInstance(TestHost host, TestNode node, TestInstance parent)
        {
            if (host == null)
            {
                throw new ArgumentNullException("host");
            }
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            Host   = host;
            Node   = node;
            Parent = parent;

            ParentPath = Parent?.GetCurrentPath();
            Path       = new TestPath(ParentPath, Node);
        }
Exemplo n.º 16
0
        TestInvoker WalkHierarchy(TestInvoker invoker, TestPath root, bool flattenHierarchy)
        {
            var path = Path.Parent;

            while (path != root)
            {
                var flags = path.Node.Flags;
                if (flattenHierarchy)
                {
                    flags |= TestFlags.FlattenHierarchy;
                }
                var node = (TestNodeInternal)path.Node;
                invoker = node.CreateInvoker(invoker, flags);
                path    = path.Parent;
            }

            return(invoker);
        }
Exemplo n.º 17
0
        public static TestResult ReadTestResult(XElement node)
        {
            if (!node.Name.LocalName.Equals("TestResult"))
            {
                throw new InternalErrorException();
            }

            var status = (TestStatus)Enum.Parse(typeof(TestStatus), node.Attribute("Status").Value);

            var path = TestPath.Read(node.Element("TestPath"));

            var result = new TestResult(path, status);

            var elapsedTime = node.Element("ElapsedTime");

            if (elapsedTime != null)
            {
                result.ElapsedTime = TimeSpan.FromMilliseconds(int.Parse(elapsedTime.Value));
            }

            foreach (var error in node.Elements("Error"))
            {
                result.AddError(ReadError(error));
            }

            foreach (var message in node.Elements("Message"))
            {
                result.AddMessage(message.Attribute("Text").Value);
            }

            foreach (var log in node.Elements("LogEntry"))
            {
                result.AddLogMessage(ReadLogEntry(log));
            }

            foreach (var child in node.Elements("TestResult"))
            {
                result.AddChild(ReadTestResult(child));
            }

            return(result);
        }
Exemplo n.º 18
0
        public IPathResolver Resolve(TestContext ctx, IPathNode node, string parameter)
        {
            Resolve(ctx);

            if (innerNode != null)
            {
                innerNode.Resolve(ctx);

                if (!TestPath.Matches(innerNode.Tree.Host, node))
                {
                    throw new InternalErrorException();
                }
                if (parameter != null)
                {
                    return(innerNode.Parameterize(parameter));
                }
                return(innerNode);
            }

            if (parameter == null)
            {
                throw new InternalErrorException();
            }

            foreach (var child in children)
            {
                if (!TestPath.Matches(child.Path.Host, node))
                {
                    throw new InternalErrorException();
                }

                if (!parameter.Equals(child.Path.Parameter.Value))
                {
                    continue;
                }

                return(child);
            }

            throw new InternalErrorException();
        }
Exemplo n.º 19
0
        static TestName GetTestName(TestHost host, TestPath parent, ITestParameter parameter = null)
        {
            var builder = new TestNameBuilder();

            if (parent != null)
            {
                builder.Merge(parent.name);
            }
            if (host.Name != null)
            {
                if (parameter != null && ((host.Flags & TestFlags.PathHidden) == 0))
                {
                    builder.PushParameter(host.Name, parameter.Value, (host.Flags & TestFlags.Hidden) != 0);
                }
                else if ((host.Flags & TestFlags.Hidden) == 0)
                {
                    builder.PushName(host.Name);
                }
            }
            return(builder.GetName());
        }
Exemplo n.º 20
0
        public void Resolve()
        {
            if (resolved)
            {
                return;
            }

            if (Tree.Inner != null)
            {
                var innerPath = new TestPath(Tree.Inner.Host, Path);
                innerNode = new TestPathNode(Tree.Inner, innerPath);
                return;
            }

            children = new List <TestPathNode> ();
            foreach (var child in Tree.Builder.Children)
            {
                var childPath = new TestPath(child.Host, Path, child.Parameter);
                children.Add(new TestPathNode(child.TreeRoot, childPath));
            }

            resolved = true;
        }
Exemplo n.º 21
0
        TestInvoker CreateInvoker(TestContext ctx, TestPath root, bool flattenHierarchy)
        {
            Resolve(ctx);

            TestInvoker invoker = null;

            if (innerNode != null)
            {
                invoker = innerNode.CreateInvoker(ctx, root, false);
            }
            else
            {
                invoker = CreateInnerInvoker(ctx);
            }

            var flags = Node.Flags;

            if (flattenHierarchy)
            {
                flags |= TestFlags.FlattenHierarchy;
            }
            invoker = Node.CreateInvoker(invoker, flags);
            return(invoker);
        }
Exemplo n.º 22
0
        TestInvoker CreateInvoker(TestContext ctx, TestPath root, bool flattenHierarchy)
        {
            Resolve(ctx);

            TestInvoker invoker = null;

            if (innerNode != null)
            {
                invoker = innerNode.CreateInvoker(ctx, root, flattenHierarchy);
            }
            else
            {
                invoker = CreateInnerInvoker(ctx);
            }

            var node = Path.Clone();

            if (flattenHierarchy)
            {
                node.Flags |= TestFlags.FlattenHierarchy;
            }
            invoker = node.Host.CreateInvoker(node, invoker);
            return(invoker);
        }
Exemplo n.º 23
0
 public FixedParameterInstance(FixedParameterHost <T> host, TestPath path, TestInstance parent)
     : base(host, path, parent)
 {
 }
Exemplo n.º 24
0
 public ParameterizedTestInstance(ParameterizedTestHost host, TestPath path, TestInstance parent)
     : base(host, path, parent)
 {
 }
Exemplo n.º 25
0
 public TestPathTreeNode(TestPathTree tree, TestPath path)
 {
     Tree = tree;
     Path = path;
     Node = (TestNodeInternal)path.Node;
 }
Exemplo n.º 26
0
 public TestPathTreeNode(TestPathTree tree, TestPath path, TestNodeInternal node)
 {
     Tree = tree;
     Path = path;
     Node = node;
 }
Exemplo n.º 27
0
 public TestBuilderInvoker(TestBuilderHost host, TestPath path, TestInvoker inner)
 {
     Host  = host;
     Path  = path;
     Inner = inner;
 }
Exemplo n.º 28
0
 public HeavyTestInstance(HeavyTestHost host, TestPath path, TestInstance parent)
     : base(host, path, parent)
 {
 }
Exemplo n.º 29
0
 internal override TestInstance CreateInstance(TestPath path, TestInstance parent)
 {
     return(new FixedParameterInstance <T> (this, path, parent));
 }
Exemplo n.º 30
0
 internal override TestInstance CreateInstance(TestPath path, TestInstance parent)
 {
     return(new CustomTestInstance(this, path, parent, HostType, UseFixtureInstance));
 }