Skip to content

Commit

Permalink
Merge pull request #351 from JosephWoodward/ShouldBeNullNotNullDocs
Browse files Browse the repository at this point in the history
Added ShouldBeNullNotNull docs
  • Loading branch information
JakeGinnivan committed Jan 9, 2016
2 parents 799a84f + 0313ddd commit 136c73e
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 0 deletions.
24 changes: 24 additions & 0 deletions docs/assertions/shouldBeNullShouldNotBeNull.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
ShouldBeNull/NotBeNull
===========

``ShouldBeNull`` and ``ShouldNotBeNull`` allow you to check whether or not a type's reference is null.

ShouldBeNull
-------

.. literalinclude:: /../src/DocumentationExamples/CodeExamples/ShouldBeNullNotNullExamples/ShouldBeNull.codeSample.approved.txt
:language: c#

**Exception**

.. literalinclude:: /../src/DocumentationExamples/CodeExamples/ShouldBeNullNotNullExamples/ShouldBeNull.exceptionText.approved.txt

ShouldNotBeNull
-------

.. literalinclude:: /../src/DocumentationExamples/CodeExamples/ShouldBeNullNotNullExamples/ShouldNotBeNull.codeSample.approved.txt
:language: c#

**Exception**

.. literalinclude:: /../src/DocumentationExamples/CodeExamples/ShouldBeNullNotNullExamples/ShouldNotBeNull.exceptionText.approved.txt
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Shouldly has plenty of different assertions, have a look under the assertions fo
assertions/shouldNotBe
assertions/shouldMatchApproved
assertions/shouldBeTrueFalse
assertions/shouldBeNullShouldNotBeNull
exampleClasses
contributing
configuration
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
string myRef = "Hello World";
myRef.ShouldBeNull();
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
myRef
should be null but was
"Hello World"
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
string myRef = null;
myRef.ShouldNotBeNull();
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
myRef
should not be null but was
1 change: 1 addition & 0 deletions src/DocumentationExamples/DocumentationExamples.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="DocExampleWriter.cs" />
<Compile Include="ShouldBeNullNotNullExamples.cs" />
<Compile Include="ShouldBeTrueFalseExamples.cs" />
<Compile Include="ShouldMatchApprovedExamples.cs" />
<Compile Include="ShouldNotBeExamples.cs" />
Expand Down
36 changes: 36 additions & 0 deletions src/DocumentationExamples/ShouldBeNullNotNullExamples.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using Shouldly;
using Xunit;
using Xunit.Abstractions;

namespace DocumentationExamples
{
public class ShouldBeNullNotNullExamples
{
readonly ITestOutputHelper _testOutputHelper;

public ShouldBeNullNotNullExamples(ITestOutputHelper testOutputHelper)
{
_testOutputHelper = testOutputHelper;
}

[Fact]
public void ShouldBeNull()
{
DocExampleWriter.Document(() =>
{
string myRef = "Hello World";
myRef.ShouldBeNull();
}, _testOutputHelper);
}

[Fact]
public void ShouldNotBeNull()
{
DocExampleWriter.Document(() =>
{
string myRef = null;
myRef.ShouldNotBeNull();
}, _testOutputHelper);
}
}
}

0 comments on commit 136c73e

Please sign in to comment.