internal override TestInvoker CreateInvoker(TestPath path, TestInvoker invoker) { if ((Flags & TestFlags.Browsable) != 0) { invoker = new ResultGroupTestInvoker(path, invoker); } return(new ParameterizedTestInvoker(this, path, invoker)); }
public ParameterSourceInstance( ParameterSourceHost <T> host, TestPath path, TestInstance parent, ITestParameterSource <T> sourceInstance, string filter) : base(host, path, parent) { SourceInstance = sourceInstance; Filter = filter; }
internal override TestInvoker CreateInvoker(TestPath path, TestInvoker invoker) { invoker = CreateResultGroup(path, invoker); invoker = new TestBuilderInvoker(this, path, invoker); return(invoker); }
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; }
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); }
public TestPath GetCurrentPath() { if (currentPath != null) { return(currentPath); } var node = new TestNodeInternal(Instance.Host, Parameter); currentPath = new TestPath(Instance.ParentPath, node); return(currentPath); }
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); }
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); }
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)); }
TestPath GetCurrentPath() { TestPath parentPath = null; if (Parent != null) { parentPath = Parent.GetCurrentPath(); } var parameter = GetCurrentParameter(); return(new TestPath(Path.Host, parentPath, parameter)); }
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> ()); }
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; }
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); }
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); }
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); }
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); }
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); }
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(); }
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()); }
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; }
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); }
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); }
public FixedParameterInstance(FixedParameterHost <T> host, TestPath path, TestInstance parent) : base(host, path, parent) { }
public ParameterizedTestInstance(ParameterizedTestHost host, TestPath path, TestInstance parent) : base(host, path, parent) { }
public TestPathTreeNode(TestPathTree tree, TestPath path) { Tree = tree; Path = path; Node = (TestNodeInternal)path.Node; }
public TestPathTreeNode(TestPathTree tree, TestPath path, TestNodeInternal node) { Tree = tree; Path = path; Node = node; }
public TestBuilderInvoker(TestBuilderHost host, TestPath path, TestInvoker inner) { Host = host; Path = path; Inner = inner; }
public HeavyTestInstance(HeavyTestHost host, TestPath path, TestInstance parent) : base(host, path, parent) { }
internal override TestInstance CreateInstance(TestPath path, TestInstance parent) { return(new FixedParameterInstance <T> (this, path, parent)); }
internal override TestInstance CreateInstance(TestPath path, TestInstance parent) { return(new CustomTestInstance(this, path, parent, HostType, UseFixtureInstance)); }