/// <summary>
        /// Asserts that the given field sets are not equal and have different
        /// hash codes.
        /// </summary>
        /// <remarks>
        /// It's valid for non-equal objects to have the same hash code, so
        /// this test is stricter than it needs to be. However, this should happen
        /// relatively rarely.
        /// </remarks>
        /// <param name="s1"></param>
        /// <param name="s2"></param>
        private static void CheckNotEqual(UnknownFieldSet s1, UnknownFieldSet s2)
        {
            String equalsError = string.Format("{0} should not be equal to {1}", s1, s2);

            Assert.IsFalse(s1.Equals(s2), equalsError);
            Assert.IsFalse(s2.Equals(s1), equalsError);

            Assert.IsFalse(s1.GetHashCode() == s2.GetHashCode(),
                           string.Format("{0} should have a different hash code from {1}", s1, s2));
        }
        /**
         * Asserts that the given field sets are equal and have identical hash codes.
         */

        private static void CheckEqualsIsConsistent(UnknownFieldSet set)
        {
            // Object should be equal to itself.
            Assert.AreEqual(set, set);

            // Object should be equal to a copy of itself.
            UnknownFieldSet copy = UnknownFieldSet.CreateBuilder(set).Build();

            Assert.AreEqual(set, copy);
            Assert.AreEqual(copy, set);
            Assert.AreEqual(set.GetHashCode(), copy.GetHashCode());
        }
Пример #3
0
        /**
     * Asserts that the given field sets are equal and have identical hash codes.
     */

        private static void CheckEqualsIsConsistent(UnknownFieldSet set)
        {
            // Object should be equal to itself.
            Assert.AreEqual(set, set);

            // Object should be equal to a copy of itself.
            UnknownFieldSet copy = UnknownFieldSet.CreateBuilder(set).Build();
            Assert.AreEqual(set, copy);
            Assert.AreEqual(copy, set);
            Assert.AreEqual(set.GetHashCode(), copy.GetHashCode());
        }
Пример #4
0
        /// <summary>
        /// Asserts that the given field sets are not equal and have different
        /// hash codes.
        /// </summary>
        /// <remarks>
        /// It's valid for non-equal objects to have the same hash code, so
        /// this test is stricter than it needs to be. However, this should happen
        /// relatively rarely.
        /// </remarks>
        /// <param name="s1"></param>
        /// <param name="s2"></param>
        private static void CheckNotEqual(UnknownFieldSet s1, UnknownFieldSet s2)
        {
            String equalsError = string.Format("{0} should not be equal to {1}", s1, s2);
            Assert.IsFalse(s1.Equals(s2), equalsError);
            Assert.IsFalse(s2.Equals(s1), equalsError);

            Assert.IsFalse(s1.GetHashCode() == s2.GetHashCode(),
                           string.Format("{0} should have a different hash code from {1}", s1, s2));
        }