Class UniqueIDGenerator
Generates unique IDs from multiple string inputs. Used to compute the unique IDs that are used inside the test framework.
public sealed class UniqueIDGenerator : IDisposable
- Inheritance
-
UniqueIDGenerator
- Implements
- Inherited Members
- Extension Methods
Constructors
UniqueIDGenerator()
Initializes a new instance of the UniqueIDGenerator class.
public UniqueIDGenerator()
Methods
Add(string)
Add a string value into the unique ID computation.
public void Add(string value)
Parameters
valuestringThe value to be added to the unique ID computation
Compute()
Compute the unique ID for the given input values. Note that once the unique ID has been computed, no further Add(string) operations will be allowed.
public string Compute()
Returns
- string
The computed unique ID
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
ForAssembly(string, string?)
Computes a unique ID for a test assembly.
public static string ForAssembly(string assemblyPath, string? configFilePath)
Parameters
Returns
- string
The computed unique ID for the assembly
ForTest(string, int)
Computes a unique ID for a test.
public static string ForTest(string testCaseUniqueID, int testIndex)
Parameters
testCaseUniqueIDstringThe unique ID of the test case that this test belongs to.
testIndexintThe index of this test in the test case, typically starting with 0 (though a negative number may be used to prevent collisions with legitimate test indices).
Returns
ForTestCase(string, Type[]?, object?[]?)
Computes a unique ID for a test case.
public static string ForTestCase(string parentUniqueID, Type[]? testMethodGenericTypes, object?[]? testMethodArguments)
Parameters
parentUniqueIDstringThe unique ID of the parent in the hierarchy; typically the test method unique ID, but may also be the test class or test collection unique ID, when test method (and possibly test class) don't exist.
testMethodGenericTypesType[]The test method's generic types
testMethodArgumentsobject[]The test method's arguments
Returns
- string
The computed unique ID for the test case
ForTestClass(string, string?)
Computes a unique ID for a test class.
public static string? ForTestClass(string testCollectionUniqueID, string? className)
Parameters
testCollectionUniqueIDstringThe unique ID of the parent test collection for the test class
classNamestringThe optional fully qualified type name of the test class
Returns
- string
The computed unique ID for the test class (may return
nullifclassNameis null)
ForTestCollection(string, string, string?)
Computes a unique ID for a test collection.
public static string ForTestCollection(string assemblyUniqueID, string collectionDisplayName, string? collectionDefinitionClassName)
Parameters
assemblyUniqueIDstringThe unique ID of the assembly the test collection lives in
collectionDisplayNamestringThe display name of the test collection
collectionDefinitionClassNamestringThe optional class name that contains the test collection definition
Returns
- string
The computed unique ID for the test collection
ForTestMethod(string?, string?)
Computes a unique ID for a test method.
public static string? ForTestMethod(string? testClassUniqueID, string? methodName)
Parameters
testClassUniqueIDstringThe unique ID of the parent test class for the test method
methodNamestringThe optional test method name
Returns
- string
The computed unique ID for the test method (may return
nullif either the class unique ID or the method name is null)
ForType(Type)
Computes a unique ID for a Type.
public static string ForType(Type type)
Parameters
typeTypeThe type to generate an ID for