Skip to content

Instantly share code, notes, and snippets.

@ChrisMaddock
Last active February 14, 2016 00:33
Show Gist options
  • Save ChrisMaddock/8e3fb6fa1bdf1a7a722e to your computer and use it in GitHub Desktop.
Save ChrisMaddock/8e3fb6fa1bdf1a7a722e to your computer and use it in GitHub Desktop.

The EmptyCollectionConstraint tests if a Collection is empty. An ArgumentException is thrown if the collection is null.

Constructor

```C# EmptyCollectionConstraint() ```

Syntax

```C# Is.Empty ```

Examples of Use

```C# Assert.That(new int[] { }, Is.Empty); Assert.That(new int[] { 1, 2, 3 }, Is.Not.Empty); ```

Note: Is.Empty actually creates an EmptyConstraint. Subsequently applying it to an IEnumerable or ICollection causes an EmptyCollectionConstraint to be created.

The EmptyStringConstraint tests if a string is empty.

Constructor

```C# EmptyStringConstraint() ```

Syntax

```C# Is.Empty ```

Examples of Use

```C# Assert.That(string.Empty, Is.Empty); Assert.That("A String", Is.Not.Empty); ```

Note: Is.Empty actually creates an EmptyConstraint. Subsequently applying it to a string causes an EmptyStringConstraint to be created.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment