Ejemplo n.º 1
0
        /// <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));
            }
Ejemplo n.º 2
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;

                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));
            }
        }
Ejemplo n.º 3
0
        private void CopyIn(Sha1Digest t)
        {
            base.CopyIn(t);

            H1 = t.H1;
            H2 = t.H2;
            H3 = t.H3;
            H4 = t.H4;
            H5 = t.H5;

            Array.Copy(t.X, 0, X, 0, t.X.Length);
            xOff = t.xOff;
        }
Ejemplo n.º 4
0
        /// <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));
            }
        }
Ejemplo n.º 5
0
        /// <summary/>
        public void Reset(Sha1Digest other)
        {
            Sha1Digest d = (Sha1Digest)other;

            CopyIn(d);
        }
Ejemplo n.º 6
0
        private void CopyIn(Sha1Digest t)
        {
            base.CopyIn(t);

            H1 = t.H1;
            H2 = t.H2;
            H3 = t.H3;
            H4 = t.H4;
            H5 = t.H5;

            Array.Copy(t.X, 0, X, 0, t.X.Length);
            xOff = t.xOff;
        }
Ejemplo n.º 7
0
 /**
  * Copy constructor.  This will copy the state of the provided
  * message digest.
  */
 public Sha1Digest(Sha1Digest t)
     : base(t)
 {
     CopyIn(t);
 }
Ejemplo n.º 8
0
        /// <summary/>
        public void Reset(Sha1Digest other)
        {
            Sha1Digest d = (Sha1Digest)other;

            CopyIn(d);
        }
Ejemplo n.º 9
0
 /**
  * Copy constructor.  This will copy the state of the provided
  * message digest.
  */
 public Sha1Digest(Sha1Digest t)
     : base(t)
 {
     CopyIn(t);
 }
Ejemplo n.º 10
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;

                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);
            }
        }