Example #1
0
        /// <summary>
        /// Serves as a hash function for a Currency.
        /// GetHashCode is suitable for use in hashing algorithms and data
        /// structures like a hash table.
        /// </summary>
        /// <returns>A hash code for the current Currency.</returns>
        public override int GetHashCode()
        {
            int hash = (RegionInfo.ISOCurrencySymbol.GetHashCode() ^
                        ExchangeRate.GetHashCode() ^
                        IsDefault.GetHashCode() ^
                        IsActive.GetHashCode());

            foreach (Denomination denom in Denominations)
            {
                hash ^= denom.GetHashCode();
            }

            return(hash);
        }
        public void WhenTheAreEquel_ThenComparingShouldBeTrueOtherwiseFalse(ExchangeRate fx1, ExchangeRate fx2, bool areEqual)
        {
            if (areEqual)
            {
                fx1.Should().Be(fx2);
            }
            else
            {
                fx1.Should().NotBe(fx2);
            }

            if (areEqual)
            {
                fx1.GetHashCode().Should().Be(fx2.GetHashCode()); //using GetHashCode()
            }
            else
            {
                fx1.GetHashCode().Should().NotBe(fx2.GetHashCode()); //using GetHashCode()
            }
            fx1.Equals(fx2).Should().Be(areEqual);                   //using Equal()
            ExchangeRate.Equals(fx1, fx2).Should().Be(areEqual);     //using static Equals()
            (fx1 == fx2).Should().Be(areEqual);                      //using Euality operators
            (fx1 != fx2).Should().Be(!areEqual);                     //using Euality operators
        }
Example #3
0
 public override int GetHashCode()
 {
     return
         (BaseCurrencyAmount.GetHashCode()
          ^ UnixTimeStamp.GetHashCode()
          ^ CounterCurrencyAmount.GetHashCode()
          ^ ExchangeRate.GetHashCode()
          ^ OrderId.GetHashCode()
          ^ Pair.GetHashCode()
          ^ SourceExchange.GetHashCode()
          ^ TradeFee.GetHashCode()
          ^ TradeFeeCurrency.GetHashCode()
          ^ TransactionType.GetHashCode()
          ^ TransactionId.GetHashCode());
 }