Skip to content

Commit

Permalink
✨ add Expect(collection).To.Include(...)
Browse files Browse the repository at this point in the history
- which, after it was built, does pretty-much what Expect(collection).To.Contain(...) does :| but I'm all for different grammar that works the same
  • Loading branch information
fluffynuts committed Feb 15, 2024
1 parent 2efc8f1 commit 78bbae7
Show file tree
Hide file tree
Showing 90 changed files with 346 additions and 167 deletions.
2 changes: 0 additions & 2 deletions src/NExpect.Tests/ArbitraryBehaviorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
using NUnit.Framework;
using PeanutButter.RandomGenerators;
using PeanutButter.Utils;
using static NExpect.Expectations;
using static PeanutButter.RandomGenerators.RandomValueGen;

// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable UnusedMethodReturnValue.Global
Expand Down
3 changes: 0 additions & 3 deletions src/NExpect.Tests/BetterStringErrors.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
using NUnit.Framework;
using NExpect;
using NExpect.Exceptions;
using static NExpect.Expectations;
using static PeanutButter.RandomGenerators.RandomValueGen;

namespace NExpect.Tests
{
Expand Down
1 change: 0 additions & 1 deletion src/NExpect.Tests/BetterStringHandling.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using NUnit.Framework;
using NExpect.Exceptions;
using static NExpect.Expectations;

namespace NExpect.Tests
{
Expand Down
2 changes: 0 additions & 2 deletions src/NExpect.Tests/CatchingIncompleteExpectations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
using NExpect.Implementations;
using NExpect.Interfaces;
using NExpect.MatcherLogic;
using static NExpect.Expectations;
using static PeanutButter.RandomGenerators.RandomValueGen;

namespace NExpect.Tests;

Expand Down
2 changes: 0 additions & 2 deletions src/NExpect.Tests/Collections/All.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
using NExpect.Exceptions;
using NUnit.Framework;
using PeanutButter.Utils;
using static PeanutButter.RandomGenerators.RandomValueGen;
using static NExpect.Expectations;

namespace NExpect.Tests.Collections
{
Expand Down
3 changes: 1 addition & 2 deletions src/NExpect.Tests/Collections/Any.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
using NExpect.Exceptions;
using NUnit.Framework;
using PeanutButter.Utils;
using static PeanutButter.RandomGenerators.RandomValueGen;
using static NExpect.Expectations;

// ReSharper disable PossibleMultipleEnumeration

namespace NExpect.Tests.Collections
Expand Down
5 changes: 1 addition & 4 deletions src/NExpect.Tests/Collections/AtLeast.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
using System;
using System.Linq;
using System.Linq;
using NExpect.Exceptions;
using NExpect.Implementations;
using NUnit.Framework;
using PeanutButter.RandomGenerators;
using PeanutButter.Utils;
using static PeanutButter.RandomGenerators.RandomValueGen;
using static NExpect.Expectations;

// ReSharper disable InconsistentNaming
// ReSharper disable RedundantAnonymousTypePropertyName
Expand Down
2 changes: 0 additions & 2 deletions src/NExpect.Tests/Collections/AtMost.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using NExpect.Exceptions;
using NUnit.Framework;
using PeanutButter.RandomGenerators;
using static PeanutButter.RandomGenerators.RandomValueGen;
using static NExpect.Expectations;

namespace NExpect.Tests.Collections
{
Expand Down
1 change: 0 additions & 1 deletion src/NExpect.Tests/Collections/CollectionSetMatching.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using NExpect.Exceptions;
using NUnit.Framework;
using static NExpect.Expectations;

namespace NExpect.Tests.Collections;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using NExpect.Implementations;
using NExpect.Interfaces;
using NExpect.MatcherLogic;
using NUnit.Framework.Internal;

// ReSharper disable PossibleMultipleEnumeration

Expand Down
2 changes: 0 additions & 2 deletions src/NExpect.Tests/Collections/CustomEqualityTesting.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using NUnit.Framework;
using static NExpect.Expectations;
using static PeanutButter.RandomGenerators.RandomValueGen;

namespace NExpect.Tests.Collections
{
Expand Down
3 changes: 1 addition & 2 deletions src/NExpect.Tests/Collections/CustomEquivalenceTesting.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using NExpect.Exceptions;
using NUnit.Framework;
using static NExpect.Expectations;
using static PeanutButter.RandomGenerators.RandomValueGen;

// ReSharper disable ExpressionIsAlwaysNull

namespace NExpect.Tests.Collections
Expand Down
2 changes: 0 additions & 2 deletions src/NExpect.Tests/Collections/DeepEqualityTesting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
using NExpect.Exceptions;
using PeanutButter.DuckTyping.Extensions;
using PeanutButter.Utils;
using static NExpect.Expectations;
using static PeanutButter.RandomGenerators.RandomValueGen;

// ReSharper disable MemberHidesStaticFromOuterClass
// ReSharper disable MemberCanBePrivate.Global
Expand Down
2 changes: 0 additions & 2 deletions src/NExpect.Tests/Collections/DictionaryTesting.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using System;
using System.Collections.Generic;
using NUnit.Framework;
using static PeanutButter.RandomGenerators.RandomValueGen;
using NExpect.Exceptions;
using NExpect.Implementations;
using PeanutButter.Utils;
using static NExpect.Expectations;

// ReSharper disable InconsistentNaming
// ReSharper disable ExpressionIsAlwaysNull
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Collections.Generic;
using NUnit.Framework;
using static NExpect.Expectations;

// ReSharper disable UnusedAutoPropertyAccessor.Global
// ReSharper disable UnusedMember.Global
Expand Down
1 change: 0 additions & 1 deletion src/NExpect.Tests/Collections/Distinct.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.Collections.Generic;
using NExpect.Exceptions;
using NUnit.Framework;
using static NExpect.Expectations;

namespace NExpect.Tests.Collections
{
Expand Down
2 changes: 0 additions & 2 deletions src/NExpect.Tests/Collections/Emptiness.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
using System.Collections.Generic;
using NExpect.Exceptions;
using NUnit.Framework;
using static NExpect.Expectations;
using static PeanutButter.RandomGenerators.RandomValueGen;

namespace NExpect.Tests.Collections
{
Expand Down
3 changes: 1 addition & 2 deletions src/NExpect.Tests/Collections/Equivalence.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
using NExpect.Exceptions;
using NUnit.Framework;
using PeanutButter.RandomGenerators;
using static PeanutButter.RandomGenerators.RandomValueGen;
using static NExpect.Expectations;

// ReSharper disable InconsistentNaming

namespace NExpect.Tests.Collections
Expand Down
2 changes: 0 additions & 2 deletions src/NExpect.Tests/Collections/Exactly.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
using NExpect.Exceptions;
using NUnit.Framework;
using PeanutButter.RandomGenerators;
using static PeanutButter.RandomGenerators.RandomValueGen;
using static NExpect.Expectations;

namespace NExpect.Tests.Collections
{
Expand Down
90 changes: 90 additions & 0 deletions src/NExpect.Tests/Collections/Include.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
using NExpect.Exceptions;
using NUnit.Framework;

namespace NExpect.Tests.Collections
{
[TestFixture]
public class Include
{
[Test]
public void ShouldBeAbleToQuicklyTestIfCollectionIncludesValue()
{
// Arrange
var collection = new[]
{
1,
2,
3
};
// Act
Assert.That(
() =>
{
Expect(collection)
.To.Include(1);
},
Throws.Nothing
);

Assert.That(
() =>
{
Expect(collection)
.Not.To.Include(1);
},
Throws.Exception.InstanceOf<UnmetExpectationException>()
);

Assert.That(
() =>
{
Expect(collection)
.To.Not.Include(1);
},
Throws.Exception.InstanceOf<UnmetExpectationException>()
);

Assert.That(
() =>
{
Expect(collection)
.To.Include(-1);
},
Throws.Exception.InstanceOf<UnmetExpectationException>()
);

// Assert
}

[Test]
public void ShouldEmitUsefulAndGrammaticallyCorrectErrors()
{
// Arrange
// Act
Assert.That(
() =>
{
Expect(3, 4, 5)
.To.Include(1);
},
Throws.Exception.InstanceOf<UnmetExpectationException>()
.With.Message.Contains(
"Expected to find value 1 in collection"
)
);

Assert.That(
() =>
{
Expect(1, 2, 3)
.Not.To.Include(1);
},
Throws.Exception.InstanceOf<UnmetExpectationException>()
.With.Message.Contains(
"Expected not to find value 1 in collection"
)
);
// Assert
}
}
}
2 changes: 0 additions & 2 deletions src/NExpect.Tests/Collections/NameValueCollectionTesting.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using System.Collections.Specialized;
using NUnit.Framework;
using static PeanutButter.RandomGenerators.RandomValueGen;
using NExpect.Exceptions;
using NExpect.Implementations;
using static NExpect.Expectations;

// ReSharper disable InconsistentNaming
// ReSharper disable ExpressionIsAlwaysNull
Expand Down
4 changes: 1 addition & 3 deletions src/NExpect.Tests/Collections/OfType.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System.Collections.Generic;
using NUnit.Framework;
using static PeanutButter.RandomGenerators.RandomValueGen;
using NExpect;
using static NExpect.Expectations;

namespace NExpect.Tests.Collections;

[TestFixture]
Expand Down
2 changes: 0 additions & 2 deletions src/NExpect.Tests/Collections/Only.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using NExpect.Exceptions;
using NUnit.Framework;
using static PeanutButter.RandomGenerators.RandomValueGen;
using PeanutButter.RandomGenerators;
using static NExpect.Expectations;

// ReSharper disable InconsistentNaming

Expand Down
1 change: 0 additions & 1 deletion src/NExpect.Tests/Collections/PartialCollectionMatching.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using NExpect.Exceptions;
using NUnit.Framework;
using static NExpect.Expectations;

namespace NExpect.Tests.Collections;

Expand Down
9 changes: 1 addition & 8 deletions src/NExpect.Tests/Collections/Sequences.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Linq;
using NUnit.Framework;
using static PeanutButter.RandomGenerators.RandomValueGen;
using NExpect;
using NExpect.Exceptions;
using NExpect.Implementations;
using static NExpect.Expectations;

namespace NExpect.Tests.Collections
{
Expand Down
1 change: 0 additions & 1 deletion src/NExpect.Tests/Collections/SetTesting.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.Collections.Generic;
using NExpect.Exceptions;
using NUnit.Framework;
using static NExpect.Expectations;

namespace NExpect.Tests.Collections
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.Collections.ObjectModel;
using NExpect.Exceptions;
using NUnit.Framework;
using static NExpect.Expectations;

namespace NExpect.Tests.Collections
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.ObjectModel;
using NUnit.Framework;
using NExpect.Exceptions;
using static NExpect.Expectations;

namespace NExpect.Tests.Collections;

Expand Down
2 changes: 0 additions & 2 deletions src/NExpect.Tests/ComposingExpectations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
using NExpect.MatcherLogic;
using NUnit.Framework;
using PeanutButter.Utils;
using static NExpect.Expectations;
using static PeanutButter.RandomGenerators.RandomValueGen;

namespace NExpect.Tests
{
Expand Down
1 change: 0 additions & 1 deletion src/NExpect.Tests/DanglingPrepositions/A.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using NExpect.MatcherLogic;
using NUnit.Framework;
using NExpect.Interfaces;
using static NExpect.Expectations;

namespace NExpect.Tests.DanglingPrepositions
{
Expand Down
1 change: 0 additions & 1 deletion src/NExpect.Tests/DanglingPrepositions/An.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using NExpect.MatcherLogic;
using NUnit.Framework;
using NExpect.Interfaces;
using static NExpect.Expectations;

namespace NExpect.Tests.DanglingPrepositions
{
Expand Down
4 changes: 0 additions & 4 deletions src/NExpect.Tests/DanglingPrepositions/Contain.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
using System.Drawing;
using System.Linq;
using NExpect.Exceptions;
using NUnit.Framework;
using static PeanutButter.RandomGenerators.RandomValueGen;
using static NExpect.Expectations;
using NExpect.Interfaces;
using NExpect.MatcherLogic;
using PeanutButter.Utils;
using NExpect.Implementations;

namespace NExpect.Tests.DanglingPrepositions
Expand Down
2 changes: 0 additions & 2 deletions src/NExpect.Tests/DanglingPrepositions/For.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
using NExpect.MatcherLogic;
using NUnit.Framework;
using PeanutButter.Utils;
using static PeanutButter.RandomGenerators.RandomValueGen;
using static NExpect.Expectations;

// ReSharper disable ClassNeverInstantiated.Global
// ReSharper disable UnusedAutoPropertyAccessor.Global
Expand Down
1 change: 0 additions & 1 deletion src/NExpect.Tests/DanglingPrepositions/Have.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using NExpect.MatcherLogic;
using NUnit.Framework;
using PeanutButter.RandomGenerators;
using static NExpect.Expectations;

namespace NExpect.Tests.DanglingPrepositions
{
Expand Down
1 change: 0 additions & 1 deletion src/NExpect.Tests/DanglingPrepositions/Mostly.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using NExpect.Exceptions;
using NUnit.Framework;
using static NExpect.Expectations;

namespace NExpect.Tests.DanglingPrepositions;

Expand Down
Loading

0 comments on commit 78bbae7

Please sign in to comment.