Exemplo n.º 1
0
        public void Equality()
        {
            byte[] hashA = new Random().NextBytes(20);
            var    hashB = new byte[hashA.Length];

            hashA.CopyTo(hashB, 0);
            hashB[19] = (byte)(hashA[19] >= 0xff ? 0 : hashA[19] + 1);
            Assert.NotEqual(hashA, hashB);

            var l123A = new Fingerprint(ValueKind.List, 123, hashA);

            Assert.False(l123A.Equals(null));
            Assert.False(l123A.Equals("other"));

            var l123A_ = new Fingerprint(ValueKind.List, 123, hashA.ToImmutableList());

            Assert.Equal(l123A, l123A_);
            Assert.True(l123A.Equals((object)l123A_));
            Assert.Equal(l123A.GetHashCode(), l123A_.GetHashCode());
            Assert.Equal(l123A.Serialize(), l123A_.Serialize());
            Assert.True(l123A == l123A_);
            Assert.False(l123A != l123A_);

            var d123A = new Fingerprint(ValueKind.Dictionary, 123, hashA);

            Assert.NotEqual(l123A, d123A);
            Assert.False(l123A.Equals((object)d123A));
            Assert.NotEqual(l123A.GetHashCode(), d123A.GetHashCode());
            Assert.NotEqual(l123A.Serialize(), d123A.Serialize());
            Assert.False(l123A == d123A);
            Assert.True(l123A != d123A);

            var l122A = new Fingerprint(ValueKind.List, 122, hashA);

            Assert.NotEqual(l123A, l122A);
            Assert.False(l123A.Equals((object)l122A));
            Assert.NotEqual(l123A.GetHashCode(), l122A.GetHashCode());
            Assert.NotEqual(l123A.Serialize(), l122A.Serialize());
            Assert.False(l123A == l122A);
            Assert.True(l123A != l122A);

            var l123B = new Fingerprint(ValueKind.List, 123, hashB);

            Assert.NotEqual(l123A, l123B);
            Assert.False(l123A.Equals((object)l123B));
            Assert.NotEqual(l123A.GetHashCode(), l123B.GetHashCode());
            Assert.NotEqual(l123A.Serialize(), l123B.Serialize());
            Assert.False(l123A == l123B);
            Assert.True(l123A != l123B);
        }
Exemplo n.º 2
0
        public void TestHashing()
        {
            Fingerprint fp1 = new Fingerprint(65);
            Fingerprint fp2 = new Fingerprint(65);
            Fingerprint fp3 = new Fingerprint(64);
            Fingerprint fp4 = new Fingerprint(66);

            Assert.Equal(fp1.GetHashCode(), fp2.GetHashCode());
            Assert.NotEqual(fp1.GetHashCode(), fp3.GetHashCode());
            Assert.NotEqual(fp2.GetHashCode(), fp4.GetHashCode());

            fp1.Touch(32);
            Assert.NotEqual(fp1.GetHashCode(), fp2.GetHashCode());
            fp2.Touch(32);
            Assert.Equal(fp1.GetHashCode(), fp2.GetHashCode());
        }
Exemplo n.º 3
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (RegistryId.Length != 0)
            {
                hash ^= RegistryId.GetHashCode();
            }
            if (Fingerprint.Length != 0)
            {
                hash ^= Fingerprint.GetHashCode();
            }
            if (CertificateData.Length != 0)
            {
                hash ^= CertificateData.GetHashCode();
            }
            if (createdAt_ != null)
            {
                hash ^= CreatedAt.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Exemplo n.º 4
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Key.Length != 0)
            {
                hash ^= Key.GetHashCode();
            }
            if (ExpirationTimeUsec != 0L)
            {
                hash ^= ExpirationTimeUsec.GetHashCode();
            }
            if (Fingerprint.Length != 0)
            {
                hash ^= Fingerprint.GetHashCode();
            }
            if (Name.Length != 0)
            {
                hash ^= Name.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Exemplo n.º 5
0
        public void GetHashCodeNotEqual()
        {
            var v1 = new Fingerprint("AA");
            var v2 = new Fingerprint("AB");

            Assert.NotEqual(v1.GetHashCode(), v2.GetHashCode());
        }
Exemplo n.º 6
0
 /// <inheritdoc/>
 public override int GetHashCode()
 {
     unchecked
     {
         return((Fingerprint.GetHashCode() * 397) ^ Domain.GetHashCode());
     }
 }
Exemplo n.º 7
0
        public override int GetHashCode()
        {
            unchecked {
                int hash = 17;
                if (Country != default(string))
                {
                    hash = hash * 23 + Country.GetHashCode();
                }
                if (City != default(string))
                {
                    hash = hash * 23 + City.GetHashCode();
                }
                if (Bank != default(string))
                {
                    hash = hash * 23 + Bank.GetHashCode();
                }
                if (PostalCode != default(string))
                {
                    hash = hash * 23 + PostalCode.GetHashCode();
                }
                if (Financing != default(string))
                {
                    hash = hash * 23 + Financing.GetHashCode();
                }
                if (LastDigits != default(string))
                {
                    hash = hash * 23 + LastDigits.GetHashCode();
                }
                if (Brand != default(string))
                {
                    hash = hash * 23 + Brand.GetHashCode();
                }
                if (ExpirationMonth != default(int))
                {
                    hash = hash * 23 + ExpirationMonth.GetHashCode();
                }
                if (ExpirationYear != default(int))
                {
                    hash = hash * 23 + ExpirationYear.GetHashCode();
                }
                if (Fingerprint != default(string))
                {
                    hash = hash * 23 + Fingerprint.GetHashCode();
                }
                if (Name != default(string))
                {
                    hash = hash * 23 + Name.GetHashCode();
                }
                if (SecurityCodeCheck != default(bool))
                {
                    hash = hash * 23 + SecurityCodeCheck.GetHashCode();
                }

                return(hash);
            }
        }
Exemplo n.º 8
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = StringComparer.OrdinalIgnoreCase.GetHashCode(FullFilePath);
         hashCode = (hashCode * 397) ^ LastModifiedUtc.GetHashCode();
         hashCode = (hashCode * 397) ^ Fingerprint.GetHashCode();
         hashCode = (hashCode * 397) ^ WasCached.GetHashCode();
         return(hashCode);
     }
 }
Exemplo n.º 9
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (CustomerId != null)
         {
             hashCode = hashCode * 59 + CustomerId.GetHashCode();
         }
         if (ExpiryMonth != null)
         {
             hashCode = hashCode * 59 + ExpiryMonth.GetHashCode();
         }
         if (ExpiryYear != null)
         {
             hashCode = hashCode * 59 + ExpiryYear.GetHashCode();
         }
         if (BillingDetails != null)
         {
             hashCode = hashCode * 59 + BillingDetails.GetHashCode();
         }
         if (Id != null)
         {
             hashCode = hashCode * 59 + Id.GetHashCode();
         }
         if (Last4 != null)
         {
             hashCode = hashCode * 59 + Last4.GetHashCode();
         }
         if (PaymentMethod != null)
         {
             hashCode = hashCode * 59 + PaymentMethod.GetHashCode();
         }
         if (Fingerprint != null)
         {
             hashCode = hashCode * 59 + Fingerprint.GetHashCode();
         }
         if (Name != null)
         {
             hashCode = hashCode * 59 + Name.GetHashCode();
         }
         if (CvvCheck != null)
         {
             hashCode = hashCode * 59 + CvvCheck.GetHashCode();
         }
         if (AvsCheck != null)
         {
             hashCode = hashCode * 59 + AvsCheck.GetHashCode();
         }
         return(hashCode);
     }
 }
Exemplo n.º 10
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = Fingerprint.GetHashCode();
         hashCode = (hashCode * 397) ^ KeyID.GetHashCode();
         hashCode = (hashCode * 397) ^ UserID.GetHashCode();
         hashCode = (hashCode * 397) ^ CreationTime.GetHashCode();
         hashCode = (hashCode * 397) ^ (int)Algorithm;
         hashCode = (hashCode * 397) ^ BitLength;
         return(hashCode);
     }
 }
Exemplo n.º 11
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Bootloader.Length != 0)
            {
                hash ^= Bootloader.GetHashCode();
            }
            if (ProcVersion.Length != 0)
            {
                hash ^= ProcVersion.GetHashCode();
            }
            if (CodeName.Length != 0)
            {
                hash ^= CodeName.GetHashCode();
            }
            if (Incremental.Length != 0)
            {
                hash ^= Incremental.GetHashCode();
            }
            if (Fingerprint.Length != 0)
            {
                hash ^= Fingerprint.GetHashCode();
            }
            if (BootID.Length != 0)
            {
                hash ^= BootID.GetHashCode();
            }
            if (AndroidID.Length != 0)
            {
                hash ^= AndroidID.GetHashCode();
            }
            if (BaseBand.Length != 0)
            {
                hash ^= BaseBand.GetHashCode();
            }
            if (InnerVersion.Length != 0)
            {
                hash ^= InnerVersion.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Exemplo n.º 12
0
        public override int GetHashCode()
        {
            unchecked {
                int hash = 17;
                hash = hash * 23 + Country.GetHashCode();
                hash = hash * 23 + City.GetHashCode();
                hash = hash * 23 + Bank.GetHashCode();
                hash = hash * 23 + PostalCode.GetHashCode();
                hash = hash * 23 + Financing.GetHashCode();
                hash = hash * 23 + LastDigits.GetHashCode();
                hash = hash * 23 + Brand.GetHashCode();
                hash = hash * 23 + ExpirationMonth.GetHashCode();
                hash = hash * 23 + ExpirationYear.GetHashCode();
                hash = hash * 23 + Fingerprint.GetHashCode();
                hash = hash * 23 + Name.GetHashCode();
                hash = hash * 23 + SecurityCodeCheck.GetHashCode();

                return(hash);
            }
        }
Exemplo n.º 13
0
 /// <inheritdoc />
 public override int GetHashCode()
 {
     return(Hash.GetHashCode());
 }
Exemplo n.º 14
0
        public void TestHashing()
        {
            Fingerprint fp1 = new Fingerprint(65);
            Fingerprint fp2 = new Fingerprint(65);
            Fingerprint fp3 = new Fingerprint(64);
            Fingerprint fp4 = new Fingerprint(66);

            Assert.AreEqual(fp1.GetHashCode(), fp2.GetHashCode());
            Assert.AreNotEqual(fp1.GetHashCode(), fp3.GetHashCode());
            Assert.AreNotEqual(fp2.GetHashCode(), fp4.GetHashCode());

            fp1.Touch(32);
            Assert.AreNotEqual(fp1.GetHashCode(), fp2.GetHashCode());
            fp2.Touch(32);
            Assert.AreEqual(fp1.GetHashCode(), fp2.GetHashCode());
        }
Exemplo n.º 15
0
        public override int GetHashCode()
        {
            int hashCode = 1370361237;

            if (Id != null)
            {
                hashCode += Id.GetHashCode();
            }

            if (CardBrand != null)
            {
                hashCode += CardBrand.GetHashCode();
            }

            if (Last4 != null)
            {
                hashCode += Last4.GetHashCode();
            }

            if (ExpMonth != null)
            {
                hashCode += ExpMonth.GetHashCode();
            }

            if (ExpYear != null)
            {
                hashCode += ExpYear.GetHashCode();
            }

            if (CardholderName != null)
            {
                hashCode += CardholderName.GetHashCode();
            }

            if (BillingAddress != null)
            {
                hashCode += BillingAddress.GetHashCode();
            }

            if (Fingerprint != null)
            {
                hashCode += Fingerprint.GetHashCode();
            }

            if (CardType != null)
            {
                hashCode += CardType.GetHashCode();
            }

            if (PrepaidType != null)
            {
                hashCode += PrepaidType.GetHashCode();
            }

            if (Bin != null)
            {
                hashCode += Bin.GetHashCode();
            }

            return(hashCode);
        }
Exemplo n.º 16
0
 public override int GetHashCode() => Depth.GetHashCode() ^ Fingerprint.GetHashCode() ^ Child.GetHashCode() ^ ChainCode.GetHashCode();
Exemplo n.º 17
0
        public override int GetHashCode()
        {
            int hashCode = 424336074;

            if (Id != null)
            {
                hashCode += Id.GetHashCode();
            }

            if (AccountNumberSuffix != null)
            {
                hashCode += AccountNumberSuffix.GetHashCode();
            }

            if (Country != null)
            {
                hashCode += Country.GetHashCode();
            }

            if (Currency != null)
            {
                hashCode += Currency.GetHashCode();
            }

            if (AccountType != null)
            {
                hashCode += AccountType.GetHashCode();
            }

            if (HolderName != null)
            {
                hashCode += HolderName.GetHashCode();
            }

            if (PrimaryBankIdentificationNumber != null)
            {
                hashCode += PrimaryBankIdentificationNumber.GetHashCode();
            }

            if (SecondaryBankIdentificationNumber != null)
            {
                hashCode += SecondaryBankIdentificationNumber.GetHashCode();
            }

            if (DebitMandateReferenceId != null)
            {
                hashCode += DebitMandateReferenceId.GetHashCode();
            }

            if (ReferenceId != null)
            {
                hashCode += ReferenceId.GetHashCode();
            }

            if (LocationId != null)
            {
                hashCode += LocationId.GetHashCode();
            }

            if (Status != null)
            {
                hashCode += Status.GetHashCode();
            }
            hashCode += Creditable.GetHashCode();
            hashCode += Debitable.GetHashCode();

            if (Fingerprint != null)
            {
                hashCode += Fingerprint.GetHashCode();
            }

            if (Version != null)
            {
                hashCode += Version.GetHashCode();
            }

            if (BankName != null)
            {
                hashCode += BankName.GetHashCode();
            }

            return(hashCode);
        }