-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
⬆️ upgrade pb source dependency for safer recursive stringification
- Loading branch information
1 parent
0df78d5
commit 6b93fe5
Showing
2 changed files
with
65 additions
and
1 deletion.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
src/NExpect.Matchers.AspNetCore.Tests/TestComparingAspNetCoreTypes.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using Microsoft.AspNetCore.Http; | ||
using NExpect.Exceptions; | ||
using NSubstitute; | ||
using NUnit.Framework; | ||
using PeanutButter.TestUtils.AspNetCore.Builders; | ||
using static NExpect.Expectations; | ||
|
||
namespace NExpect.Matchers.AspNet.Tests | ||
{ | ||
[TestFixture] | ||
public class TestComparingAspNetCoreTypes | ||
{ | ||
[Test] | ||
public void ShouldBeAbleToPerformDeepEqualityTesting() | ||
{ | ||
// Arrange | ||
var item1 = new { Path = new PathString("/moo") }; | ||
var item2 = new { Path = new PathString("/moo") }; | ||
var item3 = new { Path = new PathString("/cow") }; | ||
// Act | ||
Assert.That(() => | ||
{ | ||
Expect(item1) | ||
.Not.To.Deep.Equal(item3); | ||
}, Throws.Nothing); | ||
|
||
Assert.That(() => | ||
{ | ||
Expect(item1) | ||
.Not.To.Deep.Equal(item3); | ||
}, Throws.Nothing); | ||
|
||
Assert.That(() => | ||
{ | ||
Expect(item1) | ||
.To.Deep.Equal(item3); | ||
}, Throws.Exception.InstanceOf<UnmetExpectationException>()); | ||
|
||
Assert.That(() => | ||
{ | ||
Expect(item1) | ||
.Not.To.Deep.Equal(item2); | ||
}, Throws.Exception.InstanceOf<UnmetExpectationException>()); | ||
// Assert | ||
} | ||
|
||
[Test] | ||
public void ShouldNotStackOverflowWhenAttemptingToStringifyHttpContext() | ||
{ | ||
// Arrange | ||
// duplicates conditions in the wild | ||
var accessor = Substitute.For<IHttpContextAccessor>(); | ||
var ctx = HttpContextBuilder.BuildDefault(); | ||
accessor.HttpContext.Returns(ctx); | ||
// Act | ||
Assert.That(() => | ||
{ | ||
Expect(accessor.HttpContext) | ||
.To.Be.Null(); | ||
}, Throws.Exception.InstanceOf<UnmetExpectationException>()); | ||
// Assert | ||
} | ||
} | ||
} |
Submodule PeanutButter
updated
130 files