Skip to content
This repository

Added ShouldNotExist assertion to Nancy.Testing #708

Merged
merged 1 commit into from almost 2 years ago

2 participants

James Sconfitto Andreas Håkansson
James Sconfitto

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

Andreas Håkansson thecodejunkie merged commit 8698917 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Aug 14, 2012
James Sconfitto jugglingnutcase Added ShouldNotExist assertion to Nancy.Testing d671266
This page is out of date. Refresh to see the latest.
10 src/Nancy.Testing.Tests/AssertExtensionsTests.cs
@@ -43,6 +43,16 @@ public void Should_not_throw_exception_when_id_does_exist()
43 43 }
44 44
45 45 [Fact]
  46 + public void Should_detect_nonexistence()
  47 + {
  48 + // Given, When
  49 + var result = Record.Exception(() => this.query["#jamesIsAwesome"].ShouldNotExist());
  50 +
  51 + // Then
  52 + Assert.Null(result);
  53 + }
  54 +
  55 + [Fact]
46 56 public void Should_not_throw_exception_when_id_that_should_only_exists_once_only_exists_once()
47 57 {
48 58 // Given, When
10 src/Nancy.Testing/AssertExtensions.cs
@@ -31,6 +31,16 @@ public static AndConnector<QueryWrapper> ShouldExist(this QueryWrapper query)
31 31 }
32 32
33 33 /// <summary>
  34 + /// Asserts that an element does not exist
  35 + /// </summary>
  36 + public static AndConnector<QueryWrapper> ShouldNotExist(this QueryWrapper query)
  37 + {
  38 + Asserts.False(query.Any());
  39 +
  40 + return new AndConnector<QueryWrapper>(query);
  41 + }
  42 +
  43 + /// <summary>
34 44 /// Asserts that an element or element should exist one, and only once
35 45 /// </summary>
36 46 public static AndConnector<NodeWrapper> ShouldExistOnce(this QueryWrapper query)

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.