Esempio n. 1
0
        public virtual bool Equals(ICollectionValue <T> other)
        {
            // Prepare CopyTo()
            var padding       = 2;
            var expectedArray = new T[Count + 2 * padding];

            CopyTo(expectedArray, padding);
            var actualArray = new T[other.Count + 2 * padding];

            other.CopyTo(actualArray, padding);

            return
                // Properties
                (AllowsNull == other.AllowsNull &&
                 Count == other.Count &&
                 CountSpeed == other.CountSpeed &&
                 IsEmpty == other.IsEmpty

                 // Pure methods
                 && (!HasChoose || Choose().IsSameAs(other.Choose())) &&
                 (_sequenced ? expectedArray.SequenceEqual(actualArray, EqualityComparer) : expectedArray.UnsequenceEqual(actualArray, EqualityComparer)) &&
                 (_sequenced ? this.SequenceEqual(other, EqualityComparer) : this.UnsequenceEqual(other, EqualityComparer))
                 // Show() is tested with ToString()
                 && (_sequenced ? ToArray().SequenceEqual(other.ToArray(), EqualityComparer) : ToArray().UnsequenceEqual(other.ToArray(), EqualityComparer)) &&
                 (!_sequenced || ToString().Equals(other.ToString())));  // TODO: Should they always return the same result? Couldn't this differ between collection types?
        }
 /// <summary>
 /// Copy the items of the wrapped collection to an array
 /// </summary>
 /// <param name="a">The array</param>
 /// <param name="i">Starting offset</param>
 public virtual void CopyTo(T[] a, int i)
 {
     collectionvalue.CopyTo(a, i);
 }