Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Pipeline/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ partial class Build : NukeBuild
/// <para />
/// Afterward, you can update the package reference in `Directory.Packages.props` and reset this flag.
/// </summary>
readonly BuildScope BuildScope = BuildScope.Default;
readonly BuildScope BuildScope = BuildScope.CoreOnly;

[Parameter("Github Token")] readonly string GithubToken;

Expand Down
5 changes: 5 additions & 0 deletions Source/aweXpect.Core/Options/CollectionMatchOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,11 @@ private static IEnumerable<string> IncorrectItemsError<T>(Dictionary<int, (T Ite
private static IEnumerable<string> MissingItemsError<T>(int total, List<T> missingItems,
EquivalenceRelations equivalenceRelation, bool ignoringDuplicates)
{
if (total == 0)
{
yield break;
}

bool hasMissingItems = missingItems.Any();
if (total == missingItems.Count)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ await That(Act).Throws<XunitException>()
Expected that subject
contains collection expected in order,
but it lacked all 3 expected items

Collection:
[]

Expand All @@ -100,7 +100,7 @@ await That(Act).Throws<XunitException>()
Expected that subject
contains collection expected in order,
but it lacked all 10 expected items

Collection:
[
1,
Expand Down Expand Up @@ -131,6 +131,18 @@ but it lacked all 10 expected items
""");
}

[Fact]
public async Task WhenExpectedIsEmpty_ShouldSucceed()
{
IAsyncEnumerable<int> subject = ToAsyncEnumerable(Enumerable.Range(1, 11));
IEnumerable<int> expected = [];

async Task Act()
=> await That(subject).Contains(expected);

await That(Act).DoesNotThrow();
}

[Fact]
public async Task WhenExpectedIsNull_ShouldFail()
{
Expand Down Expand Up @@ -184,7 +196,7 @@ contained item "e" at index 4 instead of "y" and
"x",
"y",
"z"

Collection:
[
"a",
Expand Down Expand Up @@ -220,7 +232,7 @@ await That(Act).Throws<XunitException>()
Expected that subject
contains collection expected in order,
but it lacked all 6 expected items

Collection:
[
"b",
Expand Down Expand Up @@ -544,7 +556,7 @@ await That(Act).Throws<XunitException>()
Expected that subject
contains collection expected in order ignoring duplicates,
but it lacked all 3 unique expected items

Collection:
[]

Expand All @@ -571,7 +583,7 @@ await That(Act).Throws<XunitException>()
Expected that subject
contains collection expected in order ignoring duplicates,
but it lacked all 2 unique expected items

Collection:
[]

Expand All @@ -598,7 +610,7 @@ await That(Act).Throws<XunitException>()
Expected that subject
contains collection expected in order ignoring duplicates,
but it lacked all 10 unique expected items

Collection:
[
1,
Expand Down Expand Up @@ -629,6 +641,35 @@ but it lacked all 10 unique expected items
""");
}

[Fact]
public async Task WhenExpectedIsEmpty_ShouldSucceed()
{
IAsyncEnumerable<int> subject = ToAsyncEnumerable(Enumerable.Range(1, 11));
IEnumerable<int> expected = [];

async Task Act()
=> await That(subject).Contains(expected).IgnoringDuplicates();

await That(Act).DoesNotThrow();
}

[Fact]
public async Task WhenExpectedIsNull_ShouldFail()
{
IAsyncEnumerable<int> subject = ToAsyncEnumerable(Enumerable.Range(1, 11));
IEnumerable<int>? expected = null;

async Task Act()
=> await That(subject).Contains(expected!).IgnoringDuplicates();

await That(Act).Throws<XunitException>()
.WithMessage("""
Expected that subject
contains collection expected in order ignoring duplicates,
but it cannot compare to <null>
""");
}

[Fact]
public async Task WithAdditionalAndMissingItems_ShouldFail()
{
Expand All @@ -649,7 +690,7 @@ contained item "e" at index 4 instead of "y" and
"x",
"y",
"z"

Collection:
[
"a",
Expand Down Expand Up @@ -685,7 +726,7 @@ await That(Act).Throws<XunitException>()
Expected that subject
contains collection expected in order ignoring duplicates,
but it lacked all 5 unique expected items

Collection:
[
"b",
Expand Down Expand Up @@ -966,7 +1007,7 @@ await That(Act).Throws<XunitException>()
Expected that subject
contains collection expected in any order,
but it lacked all 3 expected items

Collection:
[]

Expand All @@ -993,7 +1034,7 @@ await That(Act).Throws<XunitException>()
Expected that subject
contains collection expected in any order,
but it lacked all 10 expected items

Collection:
[
1,
Expand Down Expand Up @@ -1024,6 +1065,35 @@ but it lacked all 10 expected items
""");
}

[Fact]
public async Task WhenExpectedIsEmpty_ShouldSucceed()
{
IAsyncEnumerable<int> subject = ToAsyncEnumerable(Enumerable.Range(1, 11));
IEnumerable<int> expected = [];

async Task Act()
=> await That(subject).Contains(expected).InAnyOrder();

await That(Act).DoesNotThrow();
}

[Fact]
public async Task WhenExpectedIsNull_ShouldFail()
{
IAsyncEnumerable<int> subject = ToAsyncEnumerable(Enumerable.Range(1, 11));
IEnumerable<int>? expected = null;

async Task Act()
=> await That(subject).Contains(expected!).InAnyOrder();

await That(Act).Throws<XunitException>()
.WithMessage("""
Expected that subject
contains collection expected in any order,
but it cannot compare to <null>
""");
}

[Fact]
public async Task WithAdditionalAndMissingItems_ShouldFail()
{
Expand Down Expand Up @@ -1379,7 +1449,7 @@ await That(Act).Throws<XunitException>()
Expected that subject
contains collection expected in any order ignoring duplicates,
but it lacked all 3 unique expected items

Collection:
[]

Expand Down Expand Up @@ -1408,7 +1478,7 @@ await That(Act).Throws<XunitException>()
Expected that subject
contains collection expected in any order ignoring duplicates,
but it lacked all 2 unique expected items

Collection:
[]

Expand All @@ -1435,7 +1505,7 @@ await That(Act).Throws<XunitException>()
Expected that subject
contains collection expected in any order ignoring duplicates,
but it lacked all 10 unique expected items

Collection:
[
1,
Expand Down Expand Up @@ -1466,6 +1536,35 @@ but it lacked all 10 unique expected items
""");
}

[Fact]
public async Task WhenExpectedIsEmpty_ShouldSucceed()
{
IAsyncEnumerable<int> subject = ToAsyncEnumerable(Enumerable.Range(1, 11));
IEnumerable<int> expected = [];

async Task Act()
=> await That(subject).Contains(expected).InAnyOrder().IgnoringDuplicates();

await That(Act).DoesNotThrow();
}

[Fact]
public async Task WhenExpectedIsNull_ShouldFail()
{
IAsyncEnumerable<int> subject = ToAsyncEnumerable(Enumerable.Range(1, 11));
IEnumerable<int>? expected = null;

async Task Act()
=> await That(subject).Contains(expected!).InAnyOrder().IgnoringDuplicates();

await That(Act).Throws<XunitException>()
.WithMessage("""
Expected that subject
contains collection expected in any order ignoring duplicates,
but it cannot compare to <null>
""");
}

[Fact]
public async Task WithAdditionalAndMissingItems_ShouldFail()
{
Expand Down Expand Up @@ -1783,7 +1882,7 @@ Expected that subject
but it
did not contain any additional items and
lacked all 3 expected items

Collection:
[]

Expand All @@ -1810,7 +1909,7 @@ await That(Act).Throws<XunitException>()
Expected that subject
contains collection expected and at least one additional item in order,
but it lacked all 10 expected items

Collection:
[
1,
Expand Down Expand Up @@ -1862,7 +1961,7 @@ did not contain any additional items and
"x",
"y",
"z"

Collection:
[
"a",
Expand Down Expand Up @@ -1900,7 +1999,7 @@ Expected that subject
but it
did not contain any additional items and
lacked all 6 expected items

Collection:
[
"b",
Expand Down Expand Up @@ -2253,7 +2352,7 @@ Expected that subject
but it
did not contain any additional items and
lacked all 3 unique expected items

Collection:
[]

Expand Down Expand Up @@ -2282,7 +2381,7 @@ Expected that subject
but it
did not contain any additional items and
lacked all 2 unique expected items

Collection:
[]

Expand All @@ -2309,7 +2408,7 @@ await That(Act).Throws<XunitException>()
Expected that subject
contains collection expected and at least one additional item in order ignoring duplicates,
but it lacked all 10 unique expected items

Collection:
[
1,
Expand Down Expand Up @@ -2360,7 +2459,7 @@ contained item "e" at index 4 instead of "y" and
"x",
"y",
"z"

Collection:
[
"a",
Expand Down Expand Up @@ -2398,7 +2497,7 @@ Expected that subject
but it
did not contain any additional items and
lacked all 5 unique expected items

Collection:
[
"b",
Expand Down Expand Up @@ -2805,7 +2904,7 @@ Expected that subject
but it
did not contain any additional items and
lacked all 3 expected items

Collection:
[]

Expand All @@ -2832,7 +2931,7 @@ await That(Act).Throws<XunitException>()
Expected that subject
contains collection expected and at least one additional item in any order,
but it lacked all 10 expected items

Collection:
[
1,
Expand Down Expand Up @@ -3268,7 +3367,7 @@ Expected that subject
but it
did not contain any additional items and
lacked all 3 unique expected items

Collection:
[]

Expand Down Expand Up @@ -3299,7 +3398,7 @@ Expected that subject
but it
did not contain any additional items and
lacked all 2 unique expected items

Collection:
[]

Expand All @@ -3326,7 +3425,7 @@ await That(Act).Throws<XunitException>()
Expected that subject
contains collection expected and at least one additional item in any order ignoring duplicates,
but it lacked all 10 unique expected items

Collection:
[
1,
Expand Down
Loading