public TestPath(TestPath parent, TestNode node) { Parent = parent; Node = node; var nodes = new List <TestNode> (); var parts = new List <string> (); var arguments = new List <string> (); var friendlyArguments = new List <string> (); var parameters = new List <string> (); for (var path = this; path != null; path = path.Parent) { var current = path.Node; nodes.Add(current); if (current.PathType == TestPathType.Parameter) { if (!current.IsHidden) { parameters.Add(current.Identifier); friendlyArguments.Add(current.FriendlyParameterValue); arguments.Add(current.ParameterValue); } } else if (!current.IsHidden && !string.IsNullOrEmpty(current.Name)) { parts.Add(current.Name); } } LocalName = parts.First(); parts.Reverse(); nodes.Reverse(); parameters.Reverse(); arguments.Reverse(); friendlyArguments.Reverse(); Nodes = nodes.ToArray(); Name = string.Join(".", parts); if (parameters.Count > 0) { ParameterList = "(" + string.Join(",", parameters) + ")"; ArgumentList = "(" + string.Join(",", arguments) + ")"; FriendlyArgumentList = "(" + string.Join(",", friendlyArguments) + ")"; } else { ParameterList = ArgumentList = FriendlyArgumentList = string.Empty; } FullName = Name + ArgumentList; FullFriendlyName = Name + FriendlyArgumentList; }
internal TestResult(TestPath path, TestStatus status = TestStatus.None) { this.path = path; this.status = status; messages = new ObservableCollection <string> (); ((INotifyPropertyChanged)messages).PropertyChanged += (sender, e) => OnMessagesChanged(); children = new ObservableCollection <TestResult> (); ((INotifyPropertyChanged)children).PropertyChanged += (sender, e) => OnChildrenChanged(); errors = new ObservableCollection <Exception> (); ((INotifyPropertyChanged)errors).PropertyChanged += (sender, e) => OnErrorsChanged(); log = new ObservableCollection <TestLoggerBackend.LogEntry> (); ((INotifyPropertyChanged)log).PropertyChanged += (sender, e) => OnLogEntriesChanged(); }
public static TestPath Read(XElement root) { if (!root.Name.Equals(ElementName)) { throw new InvalidOperationException(); } TestPath current = null; foreach (var node in TestNode.ReadAllNodes(root)) { current = new TestPath(current, node); } return(current); }
public static bool Equals(TestPath first, TestPath second) { while (true) { if (first == null || second == null) { return(first == null && second == null); } if (!first.Node.Matches(second.Node)) { return(false); } first = first.Parent; second = second.Parent; } }
TestContext(TestContext parent, TestPath path, TestResult result) { this.parent = parent; this.result = result; CurrentPath = path; if (result != null) { logger = new TestLogger(TestLoggerBackend.CreateForResult(result, parent.logger)); } else { logger = parent.logger; } config = parent.config; }
public bool ParameterMatches <T> (string name = null) { if (!IsParameterized) { return(false); } if (name != null) { if (PathType != TestPathType.Parameter) { return(false); } return(Identifier.Equals(name)); } else { var friendlyName = TestPath.GetFriendlyName(typeof(T)); return(friendlyName.Equals(ParameterType)); } }
internal static bool TestEquals(TestPath first, TestPath second, TestContext ctx = null) { var serializedFirst = first.SerializePath(false).ToString(); var serializedSecond = second.SerializePath(false).ToString(); if (string.Equals(serializedFirst, serializedSecond)) { return(true); } var message = string.Format("NOT EQUAL:\n{0}\n{1}\n\n", serializedFirst, serializedSecond); if (ctx != null) { ctx.LogMessage(message); } else { System.Diagnostics.Debug.WriteLine(message); } return(false); }
public static XElement Write(TestPath path, bool debug) { var node = new XElement(ElementName); if (debug) { node.SetAttributeValue("ID", path.ID.ToString()); if (path != null && path.Parent != null) { node.SetAttributeValue("Parent", path.Parent.ID.ToString()); } } while (path != null) { var element = TestNode.WriteNode(path.Node); node.AddFirst(element); path = path.Parent; } return(node); }
internal TestContext CreateChild(TestPath path, TestResult result = null) { return(new TestContext(this, path, result)); }
internal TestResult(TestPath path, Exception error) : this(path, TestStatus.Error) { AddError(error); }