public bool AddRange(SCG.IEnumerable <T> items) { // is Valid, not disposed Requires(IsValid); // Collection must be non-read-only Requires(!IsReadOnly, CollectionMustBeNonReadOnly); // Collection must be non-fixed-sized Requires(!IsFixedSize, CollectionMustBeNonFixedSize); // Argument must be non-null Requires(items != null, ArgumentMustBeNonNull); // All items must be non-null if collection disallows null values Requires(AllowsNull || ForAll(items, item => item != null), ItemsMustBeNonNull); // The collection becomes non-empty, if items are non-empty Ensures(items.IsEmpty() || !IsEmpty); // The collection will contain the items added Ensures(ForAll(items, item => this.Contains(item, EqualityComparer))); // If items were added, the count increases; otherwise it stays the same Ensures(Result <bool>() ? Count > OldValue(Count) : Count == OldValue(Count)); // Empty enumerable returns false Ensures(!items.IsEmpty() || !Result <bool>()); // Collection doesn't change if enumerator throws an exception EnsuresOnThrow <Exception>(this.IsSameSequenceAs(OldValue(ToArray()))); // If result is false, the collection remains unchanged Ensures(Result <bool>() || this.IsSameSequenceAs(OldValue(ToArray()))); // TODO: Make more exact check of added items - especially for sets return(default(bool)); }