public void BagComparedToSelfShouldBeEqual() { var c1 = new List <string> { "1", "2", "3", "4" }; Assert.That(CollectionHelper.BagEquals(c1, c1), Is.True); }
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); }
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); }
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); }
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); }
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); }
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)); }
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); }
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)); }