Exemplo n.º 1
0
        /// <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;

#if WINDOWS_PHONE_APP
                var buffer = CryptographicBuffer.CreateFromByteArray(stream.ToArray());
                var hash   = Hasher.HashData(buffer).ToArray();
#elif DOTNETCORE
                var hash = new byte[20];
                var data = stream.ToArray();
                Hasher.BlockUpdate(data, 0, data.Length);
                Hasher.DoFinal(hash, 0);
#else
                var hash = Hasher.ComputeHash(stream);
#endif
                return(BytesToHexString(hash));
            }
        }