Contract for verifying the implementation of the generic ICollection<(Of <(T>)>).

Namespace:  MbUnit.Framework.ContractVerifiers
Assembly:  MbUnit (in MbUnit.dll) Version: 3.2.0.0 (3.2.528.0)

Syntax

C#
public class CollectionContract<TCollection, TItem> : AbstractContract
where TCollection : ICollection<TItem>
Visual Basic (Declaration)
Public Class CollectionContract(Of TCollection As ICollection(Of TItem), TItem) _
	Inherits AbstractContract

Type Parameters

TCollection
The type of the collection implementing ICollection<(Of <(T>)>).
TItem
The type of items contained in the collection.

Remarks

Built-in verifications:

  • VerifyReadOnlyProperty : The IsReadOnly property returns a value in accordance to the expected result determined in the declaration of the contract verifier, by setting the property IsReadOnly. By default, the collection is expected to be not read-only (items can be added and removed, and the collection to be cleared).
  • AddShouldThrowException : The read-only collection throws an exception when the method Add(T) is called. The test is not run when the contract property IsReadOnly is set to false.
  • RemoveShouldThrowException : The read-only collection throws an exception when the method Remove(T) is called. The test is not run when the contract property IsReadOnly is set to false.
  • ClearShouldThrowException : The read-only collection throws an exception when the method Clear()()() is called. The test is not run when the contract property IsReadOnly is set to false.
  • AddNullArgument : The collection throwns a ArgumentNullException when the method Add(T) is called with a null reference item. The test is not run when the contract property AcceptNullReference is set to true.
  • RemoveNullArgument : The collection throwns a ArgumentNullException when the method Remove(T) is called with a null reference item. The test is not run when the contract property AcceptNullReference is set to true.
  • ContainsNullArgument : The collection throws a ArgumentNullException when the method Contains(T) is called with a null reference item. The test is not run when the contract property AcceptNullReference is set to true.
  • AddItems : The collection handles correctly with the addition of new items. The method Contains(T) and the property Count are expected to return suited results as well. The case of duplicate items (object equality) is tested too; according to the value of contract property AcceptEqualItems. The test is not run when the contract property IsReadOnly is set to true.
  • RemoveItems : The collection handles correctly with the removal of items. The method Contains(T) and the property Count are expected to return suited results as well. The test is not run when the contract property IsReadOnly is set to true.
  • ClearItems : The collection is cleared as expected when the method Clear()()() is called. The test is not run when the contract property IsReadOnly is set to true.
  • CopyTo : The collection performs a copy of the items in an output array. The implementation is expected to handle properly with null arguments, and a valid or an invalid index argument.

Inheritance Hierarchy

System..::.Object
  MbUnit.Framework.ContractVerifiers..::.AbstractContract
    MbUnit.Framework.ContractVerifiers..::.CollectionContract<(Of <(TCollection, TItem>)>)
      MbUnit.Framework.ContractVerifiers..::.ListContract<(Of <(TList, TItem>)>)

See Also