Exemple #1
0
 public override int GetHashCode()
 {
     return
         (Amount.GetHashCode()
          ^ Id.GetHashCode()
          ^ Pair.GetHashCode()
          ^ Price.GetHashCode()
          ^ SourceExchange.GetHashCode()
          ^ TradeType.GetHashCode());
 }
Exemple #2
0
        public override int GetHashCode()
        {
            unchecked
            {
                var hashCode = ExchangeId != null?ExchangeId.GetHashCode() : 0;

                hashCode = (hashCode * 397) ^ (TradeType != null ? TradeType.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (BaseAsset != null ? BaseAsset.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (QuoteAsset != null ? QuoteAsset.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ TimePeriodStart.GetHashCode();
                hashCode = (hashCode * 397) ^ TimePeriodEnd.GetHashCode();
                hashCode = (hashCode * 397) ^ TimeOpen.GetHashCode();
                hashCode = (hashCode * 397) ^ TimeClose.GetHashCode();
                hashCode = (hashCode * 397) ^ PriceOpen.GetHashCode();
                hashCode = (hashCode * 397) ^ PriceClose.GetHashCode();
                hashCode = (hashCode * 397) ^ PriceLow.GetHashCode();
                hashCode = (hashCode * 397) ^ PriceHigh.GetHashCode();
                hashCode = (hashCode * 397) ^ VolumeTraded.GetHashCode();
                hashCode = (hashCode * 397) ^ TradesCount.GetHashCode();
                hashCode = (hashCode * 397) ^ (Id != null ? Id.GetHashCode() : 0);
                return(hashCode);
            }
        }
        public void TestGetHashCode()
        {
            var tradeType = new TradeType { Code = "B", Name = "Buy" };
            var hashCode = tradeType.GetHashCode();
            var clone = tradeType.Clone();

            Assert.AreNotSame(tradeType, clone);
            Assert.AreEqual(tradeType.Id.Value.GetHashCode() ^ typeof(TradeType).GetHashCode() ^
                tradeType.Code.Trim().GetHashCode() ^ tradeType.Name.Trim().GetHashCode(),
                tradeType.GetHashCode());
            Assert.AreEqual(tradeType.GetHashCode(), clone.GetHashCode());
            Assert.AreNotEqual(new TradeType { Code = "B", Name = "Buy" }.GetHashCode(),
                tradeType.GetHashCode());

            tradeType.Code = "\t B \r\n";
            Assert.AreEqual(hashCode, tradeType.GetHashCode());
            tradeType.Name = " \t Buy\r\n  ";
            Assert.AreEqual(hashCode, tradeType.GetHashCode());
            tradeType.Code = "b";
            Assert.AreNotEqual(hashCode, tradeType.GetHashCode());
            tradeType.Code = "B";
            Assert.AreEqual(hashCode, tradeType.GetHashCode());
            tradeType.Description = "Some description";
            tradeType.Ordinal = 10;
            Assert.AreEqual(hashCode, tradeType.GetHashCode());
        }