Ejemplo n.º 1
0
        public void BagComparedToSelfShouldBeEqual()
        {
            var c1 = new List <string> {
                "1", "2", "3", "4"
            };

            Assert.That(CollectionHelper.BagEquals(c1, c1), Is.True);
        }
Ejemplo n.º 2
0
        public void BagComparedToNullShouldBeInequal()
        {
            var c1 = new List <string> {
                "1", "2", "3", "4"
            };

            Assert.That(CollectionHelper.BagEquals(c1, null), Is.False);
            Assert.That(CollectionHelper.BagEquals(null, c1), Is.False);
        }
Ejemplo n.º 3
0
        public void BagsWithSameElementsButDistinctOrderShouldBeEqual()
        {
            var c1 = new List <string> {
                "1", "2", "3", "4", "2"
            };
            var c2 = new List <string> {
                "2", "1", "2", "4", "3"
            };

            Assert.That(CollectionHelper.BagEquals(c1, c2), Is.True);
        }
Ejemplo n.º 4
0
        public void BagsWithSameCountButDistinctValuesShouldBeInequal()
        {
            var c1 = new List <string> {
                "1", "2", "3", "4"
            };
            var c2 = new List <string> {
                "1", "2", "3", "3"
            };

            Assert.That(CollectionHelper.BagEquals(c1, c2), Is.False);
        }
Ejemplo n.º 5
0
        public void BagsWithSameContentShouldBeEqual()
        {
            var c1 = new List <string> {
                "1", "2", "3", "4", "2"
            };
            var c2 = new List <string> {
                "1", "2", "3", "4", "2"
            };

            Assert.That(CollectionHelper.BagEquals(c1, c2), Is.True);
        }
Ejemplo n.º 6
0
        public void BagsWithoutSameCountShouldBeInequal()
        {
            var c1 = new List <string> {
                "1", "2", "2", "1"
            };
            var c2 = new List <string> {
                "1", "2"
            };

            Assert.That(CollectionHelper.BagEquals(c1, c2), Is.False);
            Assert.That(CollectionHelper.BagEquals(c2, c1), Is.False);
        }
Ejemplo n.º 7
0
        public override bool Equals(object other)
        {
            var that = other as FilterKey;

            if (that == null || !that._filterName.Equals(_filterName))
            {
                return(false);
            }

            // BagEquals is less efficient than a DictionaryEquals, but serializing dictionaries causes issues on
            // deserialization if GetHashCode or Equals are called in its deserialization callback. And building
            // dictionaries on the fly will in most cases be worst than BagEquals, unless re-coding its short-circuits.
            return(CollectionHelper.BagEquals(
                       _filterParameters,
                       that._filterParameters,
                       NamedParameterComparer.Instance));
        }
Ejemplo n.º 8
0
        public bool Equals(QueryKey other)
        {
            if (other == null || !_sqlQueryString.Equals(other._sqlQueryString))
            {
                return(false);
            }

            if (_firstRow != other._firstRow || _maxRows != other._maxRows)
            {
                return(false);
            }

            if (!Equals(_customTransformer, other._customTransformer))
            {
                return(false);
            }

            if (_types == null)
            {
                if (other._types != null)
                {
                    return(false);
                }
            }
            else
            {
                if (other._types == null)
                {
                    return(false);
                }
                if (_types.Length != other._types.Length)
                {
                    return(false);
                }

                for (int i = 0; i < _types.Length; i++)
                {
                    if (!_types[i].Equals(other._types[i]))
                    {
                        return(false);
                    }
                    if (!Equals(_values[i], other._values[i]))
                    {
                        return(false);
                    }
                }
            }

            // BagEquals is less efficient than a SetEquals or DictionaryEquals, but serializing dictionaries causes
            // issues on deserialization if GetHashCode or Equals are called in its deserialization callback. And
            // building sets or dictionaries on the fly will in most cases be worst than BagEquals, unless re-coding
            // its short-circuits.
            if (!CollectionHelper.BagEquals(_filters, other._filters))
            {
                return(false);
            }
            if (!CollectionHelper.BagEquals(_namedParameters, other._namedParameters, NamedParameterComparer.Instance))
            {
                return(false);
            }

            if (!CollectionHelper.SequenceEquals(_multiQueriesFirstRows, other._multiQueriesFirstRows))
            {
                return(false);
            }
            if (!CollectionHelper.SequenceEquals(_multiQueriesMaxRows, other._multiQueriesMaxRows))
            {
                return(false);
            }

            if (_tenantIdentifier != other._tenantIdentifier)
            {
                return(false);
            }
            return(true);
        }
Ejemplo n.º 9
0
 public void BagNullComparedToNullShouldBeEqual()
 {
     Assert.That(CollectionHelper.BagEquals <string>(null, null), Is.True);
 }
 protected override bool AreCollectionElementsEqual(IEnumerable original, IEnumerable target)
 {
     return(CollectionHelper.BagEquals((IEnumerable <T>)original, (IEnumerable <T>)target));
 }