Exemplo n.º 1
0
        public void GetHashCode_TwoEqualInstances_ReturnSameHash(
            int numberOfPlaces, double value)
        {
            // Setup
            var    baseRoundedDouble       = new RoundedDouble(3, 1.234);
            object comparisonRoundedDouble = new RoundedDouble(numberOfPlaces, value);

            // Call
            int hash1 = baseRoundedDouble.GetHashCode();
            int hash2 = comparisonRoundedDouble.GetHashCode();

            // Assert
            Assert.AreEqual(hash1, hash2);
        }
Exemplo n.º 2
0
        public void GetHashCode_RoundedDoubleEqualToDouble_ReturnSameHashCode()
        {
            // Setup
            const double otherValue    = 4.56;
            var          roundedDouble = new RoundedDouble(2, otherValue);

            // Precondition:
            Assert.IsTrue(otherValue.Equals(roundedDouble));

            // Call
            int hash1 = roundedDouble.GetHashCode();
            int hash2 = otherValue.GetHashCode();

            // Assert
            Assert.AreEqual(hash1, hash2);
        }