Skip to content

Commit

Permalink
⬆️ upgrade pb source dependency for safer recursive stringification
Browse files Browse the repository at this point in the history
  • Loading branch information
fluffynuts committed Nov 14, 2022
1 parent 0df78d5 commit 6b93fe5
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 1 deletion.
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
}
}
}
2 changes: 1 addition & 1 deletion src/PeanutButter
Submodule PeanutButter updated 130 files

0 comments on commit 6b93fe5

Please sign in to comment.