public void DictionariesAreNotEqualBasedOnMemberCount()
        {
            var x = new Dictionary<string, object>()
            {
                { "a", 1 }
            };

            var y = new Dictionary<string, object>()
            {
                { "a", 1 },
                { "b", 2 }
            };

            var comparer = new DictionaryComparer<string, object>();
            Assert.IsFalse(comparer.Equals(x, y));
            Assert.IsFalse(comparer.GetHashCode(x) == comparer.GetHashCode(y));
        }
示例#2
0
        public void DictionariesAreNotEqualBasedOnMemberCount()
        {
            var x = new Dictionary <string, object>()
            {
                { "a", 1 }
            };

            var y = new Dictionary <string, object>()
            {
                { "a", 1 },
                { "b", 2 }
            };

            var comparer = new DictionaryComparer <string, object>();

            Assert.IsFalse(comparer.Equals(x, y));
            Assert.IsFalse(comparer.GetHashCode(x) == comparer.GetHashCode(y));
        }
        public void DictionariesAreEqual()
        {
            var x = new Dictionary<string, object>()
            {
                { "a", 1 },
                { "b", 1 }
            };

            var y = new Dictionary<string, object>()
            {
                { "a", 1 },
                { "b", 1 }
            };

            var comparer = new DictionaryComparer<string, object>();
            Assert.IsTrue(comparer.Equals(x, y));
            Assert.IsTrue(comparer.GetHashCode(x) == comparer.GetHashCode(y));
        }
示例#4
0
        public void DictionariesAreEqual()
        {
            var x = new Dictionary <string, object>()
            {
                { "a", 1 },
                { "b", 1 }
            };

            var y = new Dictionary <string, object>()
            {
                { "a", 1 },
                { "b", 1 }
            };

            var comparer = new DictionaryComparer <string, object>();

            Assert.IsTrue(comparer.Equals(x, y));
            Assert.IsTrue(comparer.GetHashCode(x) == comparer.GetHashCode(y));
        }
示例#5
0
        public override int GetHashCode()
        {
            int hashCode = -1995647028;

            hashCode = hashCode * -1521134295 + this.LastDesiredVersion.GetHashCode();
            hashCode = hashCode * -1521134295 + this.SchemaVersion.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <VersionInfo> .Default.GetHashCode(this.Version);

            hashCode = hashCode * -1521134295 + EqualityComparer <DeploymentStatus> .Default.GetHashCode(this.LastDesiredStatus);

            hashCode = hashCode * -1521134295 + EqualityComparer <IRuntimeInfo> .Default.GetHashCode(this.RuntimeInfo);

            hashCode = hashCode * -1521134295 + this.SystemModules.GetHashCode();
            hashCode = hashCode * -1521134295 + StringModuleDictionaryComparer.GetHashCode(this.Modules.ToImmutableDictionary());
            return(hashCode);
        }
示例#6
0
 public override int GetHashCode()
 {
     unchecked
     {
         //We are ignoring this here because, we only change the name of the module on Creation. This
         //is needed because the name is not part of the body of Json equivalent to IModule, it is on the key of the json.
         // ReSharper disable NonReadonlyMemberInGetHashCode
         int hashCode = (this.Name != null ? this.Name.GetHashCode() : 0);
         // ReSharper restore NonReadonlyMemberInGetHashCode
         hashCode = (hashCode * 397) ^ (this.Version != null ? this.Version.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (this.Type != null ? this.Type.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (int)this.DesiredStatus;
         hashCode = (hashCode * 397) ^ (this.Config != null ? this.Config.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ this.RestartPolicy.GetHashCode();
         hashCode = (hashCode * 397) ^ EnvDictionaryComparer.GetHashCode(this.Env);
         return(hashCode);
     }
 }
示例#7
0
 public override int GetHashCode() => 1729798618 + ModuleDictionaryComparer.GetHashCode(this.Modules.ToImmutableDictionary());