/// <summary> /// Gets the unique ID for the test case. /// </summary> private string GetUniqueID(ITestMethod testMethod) { if (testMethod is null) { throw new ArgumentNullException(nameof(testMethod)); } using (var stream = new MemoryStream()) { var assemblyName = testMethod.TestClass.TestCollection.TestAssembly.Assembly.Name; //Get just the assembly name (without version info) when obtained by reflection if (testMethod.TestClass.TestCollection.TestAssembly.Assembly is IReflectionAssemblyInfo assembly) { assemblyName = assembly.Assembly.GetName().Name; } Write(stream, assemblyName); Write(stream, testMethod.TestClass.Class.Name); Write(stream, TestNumber.ToString(CultureInfo.InvariantCulture)); stream.Position = 0; var hash = new byte[20]; var data = stream.ToArray(); var hasher = new Sha1Digest(); hasher.BlockUpdate(data, 0, data.Length); hasher.DoFinal(hash, 0); return(BytesToHexString(hash)); }
/// <summary> /// Gets the unique ID for the test case. /// </summary> protected virtual string GetUniqueID() { using (var stream = new MemoryStream()) { Write(stream, TestMethod.TestClass.TestCollection.TestAssembly.Assembly.Name); Write(stream, TestMethod.TestClass.Class.Name); Write(stream, TestMethod.Method.Name); if (TestMethodArguments != null) { Write(stream, SerializationHelper.Serialize(TestMethodArguments)); } stream.Position = 0; var hash = new byte[20]; var data = stream.ToArray(); var hasher = new Sha1Digest(); hasher.BlockUpdate(data, 0, data.Length); hasher.DoFinal(hash, 0); return(BytesToHexString(hash)); } }
/// <summary> /// Gets the unique ID for the test case. /// </summary> protected virtual string GetUniqueID() { using (var stream = new MemoryStream()) { var assemblyName = TestMethod.TestClass.TestCollection.TestAssembly.Assembly.Name; //Get just the assembly name (without version info) when obtained by reflection IReflectionAssemblyInfo assembly = TestMethod.TestClass.TestCollection.TestAssembly.Assembly as IReflectionAssemblyInfo; if (assembly != null) { assemblyName = assembly.Assembly.GetName().Name; } Write(stream, assemblyName); Write(stream, TestMethod.TestClass.Class.Name); Write(stream, TestMethod.Method.Name); if (TestMethodArguments != null) { Write(stream, SerializationHelper.Serialize(TestMethodArguments)); } var genericTypes = MethodGenericTypes; if (genericTypes != null) { for (var idx = 0; idx < genericTypes.Length; idx++) { Write(stream, TypeUtility.ConvertToSimpleTypeName(genericTypes[idx])); } } stream.Position = 0; var hash = new byte[20]; var data = stream.ToArray(); var hasher = new Sha1Digest(); hasher.BlockUpdate(data, 0, data.Length); hasher.DoFinal(hash, 0); return(BytesToHexString(hash)); } }
/// <summary> /// Gets the unique ID for the test case. /// </summary> protected virtual string GetUniqueID() { using (var stream = new MemoryStream()) { Write(stream, TestMethod.TestClass.TestCollection.TestAssembly.Assembly.Name); Write(stream, TestMethod.TestClass.Class.Name); Write(stream, TestMethod.Method.Name); if (TestMethodArguments != null) Write(stream, SerializationHelper.Serialize(TestMethodArguments)); stream.Position = 0; var hash = new byte[20]; var data = stream.ToArray(); var hasher = new Sha1Digest(); hasher.BlockUpdate(data, 0, data.Length); hasher.DoFinal(hash, 0); return BytesToHexString(hash); } }