/// <summary> /// Determines whether the specified <see cref="TestItemData"/> is equal to this instance. /// </summary> /// <param name="other">The <see cref="TestItemData"/> to compare with this instance.</param> /// <returns> /// <c>true</c> if the specified <see cref="TestItemData"/> is equal to this instance; otherwise, <c>false</c>. /// </returns> public bool Equals(TestItemData other) { if (object.ReferenceEquals(other, null)) { return(false); } if (this.GetType() != other.GetType()) { return(false); } if (object.ReferenceEquals(this.Parent, null) != object.ReferenceEquals(other.Parent, null)) { return(false); } if (object.ReferenceEquals(this.Parent, null)) { return(this.Metadata.Equals(other.Metadata)); } return(this.Metadata.Equals(other.Metadata) && this.Parent.Equals(other.Parent)); }
/// <summary> /// Determines whether the specified <see cref="TestItemData"/> instance /// matches the specified <see cref="TestItem"/>. Matching, in this case, /// means that both objects have the same metadata, and all of their /// parents have the same metadata. /// </summary> /// <param name="testItemData">The <see cref="TestItemData"/> to compare with the <see cref="TestItem"/>.</param> /// <param name="other">The <see cref="TestItem"/> to consider.</param> /// <returns> /// true if this <see cref="TestItemData"/> matches the specified /// <see cref="TestItem"/>. Otherwise, false. /// </returns> public static bool Matches(TestItemData testItemData, TestItem other) { if (testItemData == null && other == null) { return(true); } if ((testItemData == null) != (other == null)) { return(false); } if (testItemData.TestItemType != other.GetType()) { return(false); } if (!testItemData.Metadata.Equals(other.Metadata)) { return(false); } if (object.ReferenceEquals(testItemData.Parent, null) != (other.Parent == null)) { return(false); } if (testItemData.Parent != null) { return(Matches(testItemData.Parent, other.Parent)); } return(true); }
/// <summary> /// Initializes a new instance of the <see cref="TestItemData"/> class. /// </summary> /// <param name="testItem">The test item whose data is exposed.</param> /// <param name="parent">The parent of this <see cref="TestItemData"/>, if it exists.</param> public TestItemData(TestItem testItem, TestItemData parent) : this(testItem) { this.Parent = parent; }