| | | 1 | | using System; |
| | | 2 | | using System.Threading; |
| | | 3 | | |
| | | 4 | | namespace DirectSight.Parser.Analysis; |
| | | 5 | | |
| | | 6 | | /// <summary> |
| | | 7 | | /// Name of a test method. |
| | | 8 | | /// </summary> |
| | | 9 | | public class TestMethod |
| | | 10 | | { |
| | | 11 | | /// <summary> |
| | | 12 | | /// Counter for unique ids. |
| | | 13 | | /// </summary> |
| | | 14 | | private static long counter = 0; |
| | | 15 | | |
| | | 16 | | /// <summary> |
| | | 17 | | /// Initializes a new instance of the <see cref="TestMethod" /> class. |
| | | 18 | | /// </summary> |
| | | 19 | | /// <param name="name">The name.</param> |
| | | 20 | | /// <param name="shortName">The short name.</param> |
| | 455 | 21 | | internal TestMethod(string name, string shortName) |
| | 455 | 22 | | { |
| | 455 | 23 | | this.Name = name ?? throw new ArgumentNullException(nameof(name)); |
| | 455 | 24 | | this.ShortName = shortName ?? throw new ArgumentNullException(nameof(shortName)); |
| | 455 | 25 | | this.Id = Interlocked.Increment(ref counter); |
| | 455 | 26 | | } |
| | | 27 | | |
| | | 28 | | /// <summary> |
| | | 29 | | /// Gets the name. |
| | | 30 | | /// </summary> |
| | | 31 | | /// <value> |
| | | 32 | | /// The name. |
| | | 33 | | /// </value> |
| | 16832 | 34 | | public string Name { get; } |
| | | 35 | | |
| | | 36 | | /// <summary> |
| | | 37 | | /// Gets the short name. |
| | | 38 | | /// </summary> |
| | | 39 | | /// <value> |
| | | 40 | | /// The short name. |
| | | 41 | | /// </value> |
| | 208 | 42 | | public string ShortName { get; } |
| | | 43 | | |
| | | 44 | | /// <summary> |
| | | 45 | | /// Gets the id of the test method. |
| | | 46 | | /// </summary> |
| | | 47 | | /// <value> |
| | | 48 | | /// The id. |
| | | 49 | | /// </value> |
| | 2260 | 50 | | public long Id { get; } |
| | | 51 | | |
| | | 52 | | /// <summary> |
| | | 53 | | /// Returns a <see cref="string" /> that represents this instance. |
| | | 54 | | /// </summary> |
| | | 55 | | /// <returns> |
| | | 56 | | /// A <see cref="string" /> that represents this instance. |
| | | 57 | | /// </returns> |
| | | 58 | | public override string ToString() |
| | 0 | 59 | | { |
| | 0 | 60 | | return this.Name; |
| | 0 | 61 | | } |
| | | 62 | | |
| | | 63 | | /// <summary> |
| | | 64 | | /// Determines whether the specified <see cref="object"/> is equal to this instance. |
| | | 65 | | /// </summary> |
| | | 66 | | /// <param name="obj">The <see cref="object"/> to compare with this instance.</param> |
| | | 67 | | /// <returns> |
| | | 68 | | /// <c>true</c> if the specified <see cref="object"/> is equal to this instance; otherwise, <c>false</c>. |
| | | 69 | | /// </returns> |
| | | 70 | | public override bool Equals(object obj) |
| | 4473 | 71 | | { |
| | 4473 | 72 | | if (obj == null || !obj.GetType().Equals(typeof(TestMethod))) |
| | 0 | 73 | | { |
| | 0 | 74 | | return false; |
| | | 75 | | } |
| | | 76 | | else |
| | 4473 | 77 | | { |
| | 4473 | 78 | | var testMethod = (TestMethod)obj; |
| | 4473 | 79 | | return testMethod.Name.Equals(this.Name); |
| | | 80 | | } |
| | 4473 | 81 | | } |
| | | 82 | | |
| | | 83 | | /// <summary> |
| | | 84 | | /// Returns a hash code for this instance. |
| | | 85 | | /// </summary> |
| | | 86 | | /// <returns> |
| | | 87 | | /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. |
| | | 88 | | /// </returns> |
| | 7834 | 89 | | public override int GetHashCode() => this.Name.GetHashCode(); |
| | | 90 | | } |