-
Notifications
You must be signed in to change notification settings - Fork 341
Writes the test properties, CSSProjectStructure, CSSIteration, WorkItemIds and Description to the TRX log #1801
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
6f0a12f
Writes the test properties and workitem ids to the TRX log in accorda…
dotMorten ec5ddb4
Added support for Descrition and ensure owner and priority aren't als…
dotMorten ca7dfc7
Ensure The two CSS traits doesn't get included in the test properties
dotMorten a2296dc
Fix typo
dotMorten bc1b9a1
Added support for CSS Project Structure and CSS Iteration properties
dotMorten b2879a6
Merge branch 'master' into TrxProperties
mayankbansal018 f3b710c
Merge branch 'master' into TrxProperties
mayankbansal018 89d75e2
Merge branch 'master' into TrxProperties
mayankbansal018 3a833cf
Merge branch 'master' into TrxProperties
mayankbansal018 5cc3494
Change private field to protected for consistency
dotMorten 21858c4
Fixed a few nit issues
dotMorten 934ff29
Merge branch 'master' into TrxProperties
singhsarab File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
245 changes: 245 additions & 0 deletions
245
src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestPropertyItems.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,245 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
|
||
| namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel | ||
| { | ||
| using System; | ||
| using System.Diagnostics; | ||
| using System.Text; | ||
|
|
||
| using Microsoft.TestPlatform.Extensions.TrxLogger.Utility; | ||
| using Microsoft.TestPlatform.Extensions.TrxLogger.XML; | ||
|
|
||
| #region TestPropertyItem | ||
| /// <summary> | ||
| /// Stores a string which categorizes the Test | ||
| /// </summary> | ||
| internal sealed class TestPropertyItem : IXmlTestStore | ||
| { | ||
| #region Fields | ||
| [StoreXmlSimpleField(Location = "Key", DefaultValue = "")] | ||
| private string key = string.Empty; | ||
|
|
||
| [StoreXmlSimpleField(Location = "Value", DefaultValue = "")] | ||
| private string value = string.Empty; | ||
|
|
||
| #endregion | ||
|
|
||
| #region Constructors | ||
| /// <summary> | ||
| /// Create a new item with the key/value set | ||
| /// </summary> | ||
| /// <param name="key">The key.</param> | ||
| /// <param name="value">The value.</param> | ||
| public TestPropertyItem(string key, string value) | ||
| { | ||
| // Treat null as empty. | ||
| if (string.IsNullOrEmpty(key)) | ||
| throw new ArgumentNullException(); | ||
|
|
||
| if (value == null) | ||
| { | ||
| value = String.Empty; | ||
| } | ||
|
|
||
| this.key = key; | ||
| this.value = value; | ||
| } | ||
|
|
||
| #endregion | ||
|
|
||
| #region Properties/Methods | ||
| /// <summary> | ||
| /// Gets the Key for this TestProperty | ||
| /// </summary> | ||
| public string Key | ||
| { | ||
| get | ||
| { | ||
| return this.key; | ||
| } | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets the Value for this TestProperty | ||
| /// </summary> | ||
| public string Value | ||
| { | ||
| get | ||
| { | ||
| return this.value; | ||
| } | ||
| } | ||
|
|
||
| #endregion | ||
|
|
||
| #region Methods - overrides | ||
| /// <summary> | ||
| /// Compare the values of the items | ||
| /// </summary> | ||
| /// <param name="other">Value being compared to.</param> | ||
| /// <returns>True if the values are the same and false otherwise.</returns> | ||
| public override bool Equals(object other) | ||
| { | ||
| TestPropertyItem otherItem = other as TestPropertyItem; | ||
| if (otherItem == null) | ||
| { | ||
| return false; | ||
| } | ||
| return String.Equals(this.key, otherItem.key, StringComparison.OrdinalIgnoreCase) && String.Equals(this.value, otherItem.value, StringComparison.Ordinal); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Convert the property name to a hashcode | ||
| /// </summary> | ||
| /// <returns>Hashcode of the category.</returns> | ||
| public override int GetHashCode() | ||
| { | ||
| return this.key.ToUpperInvariant().GetHashCode() ^ this.value.GetHashCode(); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Convert the property name to a string | ||
| /// </summary> | ||
| /// <returns>The property.</returns> | ||
| public override string ToString() | ||
| { | ||
| return this.key + " = " + this.value; | ||
| } | ||
| #endregion | ||
|
|
||
| #region IXmlTestStore Members | ||
|
|
||
| /// <summary> | ||
| /// Saves the class under the XmlElement. | ||
| /// </summary> | ||
| /// <param name="element"> XmlElement element </param> | ||
| /// <param name="parameters"> XmlTestStoreParameters parameters</param> | ||
| public void Save(System.Xml.XmlElement element, XmlTestStoreParameters parameters) | ||
| { | ||
| new XmlPersistence().SaveSingleFields(element, this, parameters); | ||
| } | ||
|
|
||
| #endregion | ||
| } | ||
| #endregion | ||
|
|
||
| #region TestPropertyItemCollection | ||
| /// <summary> | ||
| /// A collection of strings which categorize the test. | ||
| /// </summary> | ||
| internal sealed class TestPropertyItemCollection : EqtBaseCollection<TestPropertyItem> | ||
| { | ||
| #region Constructors | ||
| /// <summary> | ||
| /// Creates an empty TestPropertyItemCollection. | ||
| /// </summary> | ||
| public TestPropertyItemCollection() | ||
| { | ||
| childElementName = "Property"; | ||
| } | ||
|
|
||
| #endregion | ||
|
|
||
| #region Methods | ||
|
|
||
| /// <summary> | ||
| /// Adds the property. | ||
| /// </summary> | ||
| /// <param name="key">Key to be added.</param> | ||
| /// <param name="value">Value to be added.</param> | ||
| public void Add(string key, string value) | ||
| { | ||
| this.Add(new TestPropertyItem(key, value)); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Adds the property. | ||
| /// </summary> | ||
| /// <param name="item">Property to be added.</param> | ||
| public override void Add(TestPropertyItem item) | ||
| { | ||
| EqtAssert.ParameterNotNull(item, "item"); | ||
|
|
||
| // Don't add empty items. | ||
| if (!String.IsNullOrEmpty(item.Key)) | ||
| { | ||
| base.Add(item); | ||
| } | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Convert the TestPropertyItemCollection to a string. | ||
| /// each item is surrounded by a comma (,) | ||
| /// </summary> | ||
| /// <returns></returns> | ||
| public override string ToString() | ||
| { | ||
| StringBuilder returnString = new StringBuilder(); | ||
| if (this.Count > 0) | ||
| { | ||
| returnString.Append(","); | ||
| foreach (TestPropertyItem item in this) | ||
| { | ||
| returnString.Append(item.ToString()); | ||
| returnString.Append(","); | ||
| } | ||
| } | ||
|
|
||
| return returnString.ToString(); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Compare the collection items | ||
| /// </summary> | ||
| /// <param name="obj">other collection</param> | ||
| /// <returns>true if the collections contain the same items</returns> | ||
| public override bool Equals(object obj) | ||
| { | ||
| TestPropertyItemCollection other = obj as TestPropertyItemCollection; | ||
| bool result = false; | ||
|
|
||
| if (other == null) | ||
| { | ||
| // Other object is not a TestPropertyItemCollection. | ||
| result = false; | ||
| } | ||
| else if (Object.ReferenceEquals(this, other)) | ||
| { | ||
| // The other object is the same object as this one. | ||
| result = true; | ||
| } | ||
| else if (this.Count != other.Count) | ||
| { | ||
| // The count of categories in the other object does not | ||
| // match this one, so they are not equal. | ||
| result = false; | ||
| } | ||
| else | ||
| { | ||
| // Check each item and return on the first mismatch. | ||
| foreach (TestPropertyItem item in this) | ||
| { | ||
| if (!other.Contains(item)) | ||
| { | ||
| result = false; | ||
| break; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return result; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Return the hash code of this collection | ||
| /// </summary> | ||
| /// <returns>The hashcode.</returns> | ||
| public override int GetHashCode() | ||
| { | ||
| return base.GetHashCode(); | ||
| } | ||
| #endregion | ||
| } | ||
| #endregion | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.