Esempio n. 1
0
        public void TestGetHashCodeIsSameWhenTagsAreTheSame()
        {
            var tagSet1 = new ReplicaSetTagSet
            {
                new ReplicaSetTag("dc", "ny")
            };

            var tagSet2 = new ReplicaSetTagSet
            {
                new ReplicaSetTag("dc", "ny")
            };

            Assert.AreEqual(tagSet1.GetHashCode(), tagSet2.GetHashCode());
        }
Esempio n. 2
0
        /// <summary>
        /// Returns a hash code for this instance.
        /// </summary>
        /// <returns>
        /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
        /// </returns>
        public override int GetHashCode()
        {
            // see Effective Java by Joshua Bloch
            int hash = 17;

            hash = 37 * hash + _name.GetHashCode();
            hash = 37 * hash + _primary.GetHashCode();
            foreach (var member in _members)
            {
                hash = 37 * hash + member.GetHashCode();
            }
            hash = 37 * hash + _tagSet.GetHashCode();
            return(hash);
        }
        public void TestGetHashCodeIsSameWhenTagsAreTheSame()
        {
            var tagSet1 = new ReplicaSetTagSet
            {
                new ReplicaSetTag("dc", "ny")
            };

            var tagSet2 = new ReplicaSetTagSet
            {
                new ReplicaSetTag("dc", "ny")
            };

            Assert.AreEqual(tagSet1.GetHashCode(), tagSet2.GetHashCode());
        }