Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Added ShouldNotExist assertion to Nancy.Testing #708

Merged
merged 1 commit into from

2 participants

@jugglingnutcase

:bomb: Asserts the presence of non-existence :bomb:

@thecodejunkie thecodejunkie merged commit 8698917 into NancyFx:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 14, 2012
  1. @jugglingnutcase
This page is out of date. Refresh to see the latest.
View
10 src/Nancy.Testing.Tests/AssertExtensionsTests.cs
@@ -43,6 +43,16 @@ public void Should_not_throw_exception_when_id_does_exist()
}
[Fact]
+ public void Should_detect_nonexistence()
+ {
+ // Given, When
+ var result = Record.Exception(() => this.query["#jamesIsAwesome"].ShouldNotExist());
+
+ // Then
+ Assert.Null(result);
+ }
+
+ [Fact]
public void Should_not_throw_exception_when_id_that_should_only_exists_once_only_exists_once()
{
// Given, When
View
10 src/Nancy.Testing/AssertExtensions.cs
@@ -31,6 +31,16 @@ public static AndConnector<QueryWrapper> ShouldExist(this 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>
/// Asserts that an element or element should exist one, and only once
/// </summary>
public static AndConnector<NodeWrapper> ShouldExistOnce(this QueryWrapper query)
Something went wrong with that request. Please try again.