Skip to content
This repository has been archived by the owner on Jan 24, 2021. It is now read-only.

Added ShouldNotExist assertion to Nancy.Testing #708

Merged
merged 1 commit into from Sep 23, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/Nancy.Testing.Tests/AssertExtensionsTests.cs
Expand Up @@ -42,6 +42,16 @@ public void Should_not_throw_exception_when_id_does_exist()
Assert.Null(result); Assert.Null(result);
} }


[Fact]
public void Should_detect_nonexistence()
{
// Given, When
var result = Record.Exception(() => this.query["#jamesIsAwesome"].ShouldNotExist());

// Then
Assert.Null(result);
}

[Fact] [Fact]
public void Should_not_throw_exception_when_id_that_should_only_exists_once_only_exists_once() public void Should_not_throw_exception_when_id_that_should_only_exists_once_only_exists_once()
{ {
Expand Down
10 changes: 10 additions & 0 deletions src/Nancy.Testing/AssertExtensions.cs
Expand Up @@ -30,6 +30,16 @@ public static AndConnector<QueryWrapper> ShouldExist(this QueryWrapper query)
return new AndConnector<QueryWrapper>(query); return new AndConnector<QueryWrapper>(query);
} }


/// <summary>
/// Asserts that an element does not exist
/// </summary>
public static AndConnector<QueryWrapper> ShouldNotExist(this QueryWrapper query)
{
Asserts.False(query.Any());

return new AndConnector<QueryWrapper>(query);
}

/// <summary> /// <summary>
/// Asserts that an element or element should exist one, and only once /// Asserts that an element or element should exist one, and only once
/// </summary> /// </summary>
Expand Down