/// <summary> /// Computes a unique ID for a test case, to be placed into <see cref="_TestCaseMessage.TestCaseUniqueID"/> /// </summary> /// <param name="parentUniqueID">The 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.</param> /// <param name="testMethodGenericTypes">The test method's generic types</param> /// <param name="testMethodArguments">The test method's arguments</param> /// <returns>The computed unique ID for the test case</returns> public static string ForTestCase( string parentUniqueID, _ITypeInfo[]?testMethodGenericTypes, object?[]?testMethodArguments) { Guard.ArgumentNotNull(parentUniqueID); using var generator = new UniqueIDGenerator(); generator.Add(parentUniqueID); if (testMethodArguments != null) { generator.Add(SerializationHelper.Serialize(testMethodArguments)); } if (testMethodGenericTypes != null) { for (var idx = 0; idx < testMethodGenericTypes.Length; idx++) { generator.Add(TypeUtility.ConvertToSimpleTypeName(testMethodGenericTypes[idx])); } } return(generator.Compute()); }
/// <summary> /// Computes a unique ID for a test, to be placed into <see cref="_TestMessage.TestUniqueID"/> /// </summary> /// <param name="testCaseUniqueID">The unique ID of the test case that this test belongs to.</param> /// <param name="testIndex">The 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).</param> public static string ForTest( string testCaseUniqueID, int testIndex) { Guard.ArgumentNotNull(testCaseUniqueID); using var generator = new UniqueIDGenerator(); generator.Add(testCaseUniqueID); generator.Add(testIndex.ToString()); return(generator.Compute()); }
/// <summary> /// Computes a unique ID for a test collection, to be placed into <see cref="_TestCollectionMessage.TestCollectionUniqueID"/> /// </summary> /// <param name="assemblyUniqueID">The unique ID of the assembly the test collection lives in</param> /// <param name="collectionDisplayName">The display name of the test collection</param> /// <param name="collectionDefinitionClassName">The optional class name that contains the test collection definition</param> /// <returns>The computed unique ID for the test collection</returns> public static string ForTestCollection( string assemblyUniqueID, string collectionDisplayName, string?collectionDefinitionClassName) { Guard.ArgumentNotNull(assemblyUniqueID); Guard.ArgumentNotNull(collectionDisplayName); using var generator = new UniqueIDGenerator(); generator.Add(assemblyUniqueID); generator.Add(collectionDisplayName); generator.Add(collectionDefinitionClassName ?? string.Empty); return(generator.Compute()); }
public static string?ForTestMethod( string?testClassUniqueID, string?methodName) { if (testClassUniqueID == null || methodName == null) { return(null); } using var generator = new UniqueIDGenerator(); generator.Add(testClassUniqueID); generator.Add(methodName); return(generator.Compute()); }
public static string?ForTestClass( string testCollectionUniqueID, string?className) { Guard.ArgumentNotNull(testCollectionUniqueID); if (className == null) { return(null); } using var generator = new UniqueIDGenerator(); generator.Add(testCollectionUniqueID); generator.Add(className); return(generator.Compute()); }
/// <summary> /// Computes a unique ID for an assembly, to be placed into <see cref="_TestAssemblyMessage.AssemblyUniqueID"/> /// </summary> /// <param name="assemblyName">The assembly name</param> /// <param name="assemblyPath">The optional assembly path</param> /// <param name="configFilePath">The optional configuration file path</param> /// <returns>The computed unique ID for the assembly</returns> public static string ForAssembly( string assemblyName, string?assemblyPath, string?configFilePath) { Guard.ArgumentNotNullOrEmpty(assemblyName); var parsedAssemblyName = new AssemblyName(assemblyName); Guard.ArgumentNotNull("assemblyName must include a name component", parsedAssemblyName.Name, nameof(assemblyName)); using var generator = new UniqueIDGenerator(); generator.Add(parsedAssemblyName.Name); generator.Add(assemblyPath ?? string.Empty); generator.Add(configFilePath ?? string.Empty); return(generator.Compute()); }