Exemple #1
0
        public void TestIdenticalEntriesIdenticalHashCode()
        {
            ServiceEntry serviceEntry0 = new ServiceEntry(typeof(IService), "SomeKey");
            ServiceEntry serviceEntry1 = new ServiceEntry(typeof(IService), "SomeKey");

            int hashCode0 = serviceEntry0.GetHashCode();
            int hashCode1 = serviceEntry1.GetHashCode();

            Assert.Equal(hashCode0, hashCode1);
        }
Exemple #2
0
        public void TestDifferentEntriesDifferentHashCode()
        {
            ServiceEntry serviceEntry0 = new ServiceEntry(typeof(IService), "SomeKey");
            ServiceEntry serviceEntry1 = new ServiceEntry(typeof(IService1), "SomeKey");

            int hashCode0 = serviceEntry0.GetHashCode();
            int hashCode1 = serviceEntry1.GetHashCode();

            Assert.NotEqual(hashCode0, hashCode1);
        }
Exemple #3
0
        public void TestNullKeyMatches()
        {
            ServiceEntry serviceEntry0 = new ServiceEntry(null, "SomeKey");
            ServiceEntry serviceEntry1 = new ServiceEntry(null, "SomeKey");

            int hashCode0 = serviceEntry0.GetHashCode();
            int hashCode1 = serviceEntry1.GetHashCode();

            Assert.Equal(hashCode0, hashCode1);
        }
Exemple #4
0
        public void TestNullServiceMatches()
        {
            ServiceEntry serviceEntry0 = new ServiceEntry(typeof(IService), null);
            ServiceEntry serviceEntry1 = new ServiceEntry(typeof(IService), null);

            int hashCode0 = serviceEntry0.GetHashCode();
            int hashCode1 = serviceEntry1.GetHashCode();

            Assert.Equal(hashCode0, hashCode1);
        }
 public override int GetHashCode()
 {
     unchecked
     {
         int hashCode = Id;
         hashCode = (hashCode * 397) ^ (ServiceEntry != null ? ServiceEntry.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (PriceId != null ? PriceId.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (AlgoName != null ? AlgoName.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Name != null ? Name.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ UseWindow.GetHashCode();
         hashCode = (hashCode * 397) ^ MinProfit.GetHashCode();
         hashCode = (hashCode * 397) ^ Hashrate.GetHashCode();
         hashCode = (hashCode * 397) ^ Power.GetHashCode();
         hashCode = (hashCode * 397) ^ (Priority != null ? Priority.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Affinity;
         hashCode = (hashCode * 397) ^ (Folder != null ? Folder.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Command != null ? Command.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Arguments != null ? Arguments.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (DonationFolder != null ? DonationFolder.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (DonationCommand != null ? DonationCommand.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (DonationArguments != null ? DonationArguments.GetHashCode() : 0);
         return(hashCode);
     }
 }
Exemple #6
0
        public override int GetHashCode()
        {
            unchecked
            {
                // Choose large primes to avoid hashing collisions
                const int HashingBase       = (int)2166136261;
                const int HashingMultiplier = 16777619;

                int hash = HashingBase;
                hash = (hash * HashingMultiplier) ^ (!Object.ReferenceEquals(null, Id) ? Id.GetHashCode() : 0);
                hash = (hash * HashingMultiplier) ^ (!Object.ReferenceEquals(null, ServiceEntry) ? ServiceEntry.GetHashCode() : 0);
                hash = (hash * HashingMultiplier) ^ (!Object.ReferenceEquals(null, this.LastAlert) ? LastAlert.GetHashCode() : 0);
                hash = (hash * HashingMultiplier) ^ (!Object.ReferenceEquals(null, this.LastStatus) ? LastStatus.GetHashCode() : 0);
                return(hash);
            }
        }