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
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public static partial class ThatDictionary
this IThat<IDictionary<TKey, TValue>?> source,
params TKey[] expected)
{
expected.ThrowIfNullOrEmpty();
ExpectationBuilder expectationBuilder = source.Get().ExpectationBuilder;
return new ContainsValuesResult<IDictionary<TKey, TValue>, IThat<IDictionary<TKey, TValue>?>, TKey, TValue?>(
expectationBuilder.AddConstraint((it, grammars) =>
Expand All @@ -39,6 +40,7 @@ public static partial class ThatDictionary
params TKey[] expected)
where TKey : notnull
{
expected.ThrowIfNullOrEmpty();
ExpectationBuilder expectationBuilder = source.Get().ExpectationBuilder;
return new ContainsValuesResult<Dictionary<TKey, TValue>, IThat<Dictionary<TKey, TValue>?>, TKey, TValue?>(
expectationBuilder.AddConstraint((it, grammars) =>
Expand All @@ -59,6 +61,7 @@ public static AndOrResult<IDictionary<TKey, TValue>, IThat<IDictionary<TKey, TVa
this IThat<IDictionary<TKey, TValue>?> source,
params TKey[] unexpected)
{
unexpected.ThrowIfNullOrEmpty();
ExpectationBuilder expectationBuilder = source.Get().ExpectationBuilder;
return new AndOrResult<IDictionary<TKey, TValue>, IThat<IDictionary<TKey, TValue>?>>(
expectationBuilder.AddConstraint((it, grammars) =>
Expand All @@ -77,6 +80,7 @@ public static AndOrResult<Dictionary<TKey, TValue>, IThat<Dictionary<TKey, TValu
params TKey[] unexpected)
where TKey : notnull
{
unexpected.ThrowIfNullOrEmpty();
ExpectationBuilder expectationBuilder = source.Get().ExpectationBuilder;
return new AndOrResult<Dictionary<TKey, TValue>, IThat<Dictionary<TKey, TValue>?>>(
expectationBuilder.AddConstraint((it, grammars) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public static partial class ThatDictionary
this IThat<IDictionary<TKey, TValue>?> source,
params TValue[] expected)
{
expected.ThrowIfNullOrEmpty();
ExpectationBuilder expectationBuilder = source.Get().ExpectationBuilder;
return new AndOrResult<IDictionary<TKey, TValue>, IThat<IDictionary<TKey, TValue>?>>(
expectationBuilder.AddConstraint((it, grammars) =>
Expand All @@ -35,6 +36,7 @@ public static partial class ThatDictionary
params TValue[] expected)
where TKey : notnull
{
expected.ThrowIfNullOrEmpty();
ExpectationBuilder expectationBuilder = source.Get().ExpectationBuilder;
return new AndOrResult<Dictionary<TKey, TValue>, IThat<Dictionary<TKey, TValue>?>>(
expectationBuilder.AddConstraint((it, grammars) =>
Expand All @@ -53,6 +55,7 @@ public static AndOrResult<IDictionary<TKey, TValue>, IThat<IDictionary<TKey, TVa
this IThat<IDictionary<TKey, TValue>?> source,
params TValue[] unexpected)
{
unexpected.ThrowIfNullOrEmpty();
ExpectationBuilder expectationBuilder = source.Get().ExpectationBuilder;
return new AndOrResult<IDictionary<TKey, TValue>, IThat<IDictionary<TKey, TValue>?>>(
expectationBuilder.AddConstraint((it, grammars) =>
Expand All @@ -72,6 +75,7 @@ public static AndOrResult<Dictionary<TKey, TValue>, IThat<Dictionary<TKey, TValu
params TValue[] unexpected)
where TKey : notnull
{
unexpected.ThrowIfNullOrEmpty();
ExpectationBuilder expectationBuilder = source.Get().ExpectationBuilder;
return new AndOrResult<Dictionary<TKey, TValue>, IThat<Dictionary<TKey, TValue>?>>(
expectationBuilder.AddConstraint((it, grammars) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public static partial class ThatReadOnlyDictionary
this IThat<IReadOnlyDictionary<TKey, TValue>?> source,
params TKey[] expected)
{
expected.ThrowIfNullOrEmpty();
ExpectationBuilder expectationBuilder = source.Get().ExpectationBuilder;
return new ContainsValuesResult<IReadOnlyDictionary<TKey, TValue>, IThat<IReadOnlyDictionary<TKey, TValue>?>,
TKey, TValue?>(
Expand All @@ -43,6 +44,7 @@ public static partial class ThatReadOnlyDictionary
params TKey[] expected)
where TKey : notnull
{
expected.ThrowIfNullOrEmpty();
ExpectationBuilder expectationBuilder = source.Get().ExpectationBuilder;
return new ContainsValuesResult<ReadOnlyDictionary<TKey, TValue>, IThat<ReadOnlyDictionary<TKey, TValue>?>, TKey
, TValue?>(
Expand All @@ -64,6 +66,7 @@ public static AndOrResult<IReadOnlyDictionary<TKey, TValue>, IThat<IReadOnlyDict
this IThat<IReadOnlyDictionary<TKey, TValue>?> source,
params TKey[] unexpected)
{
unexpected.ThrowIfNullOrEmpty();
ExpectationBuilder expectationBuilder = source.Get().ExpectationBuilder;
return new AndOrResult<IReadOnlyDictionary<TKey, TValue>, IThat<IReadOnlyDictionary<TKey, TValue>?>>(
expectationBuilder.AddConstraint((it, grammars) =>
Expand All @@ -82,6 +85,7 @@ public static AndOrResult<ReadOnlyDictionary<TKey, TValue>, IThat<ReadOnlyDictio
params TKey[] unexpected)
where TKey : notnull
{
unexpected.ThrowIfNullOrEmpty();
ExpectationBuilder expectationBuilder = source.Get().ExpectationBuilder;
return new AndOrResult<ReadOnlyDictionary<TKey, TValue>, IThat<ReadOnlyDictionary<TKey, TValue>?>>(
expectationBuilder.AddConstraint((it, grammars) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public static AndOrResult<IReadOnlyDictionary<TKey, TValue>, IThat<IReadOnlyDict
this IThat<IReadOnlyDictionary<TKey, TValue>?> source,
params TValue[] expected)
{
expected.ThrowIfNullOrEmpty();
ExpectationBuilder expectationBuilder = source.Get().ExpectationBuilder;
return new AndOrResult<IReadOnlyDictionary<TKey, TValue>, IThat<IReadOnlyDictionary<TKey, TValue>?>>(
expectationBuilder.AddConstraint((it, grammars) =>
Expand All @@ -38,6 +39,7 @@ public static AndOrResult<ReadOnlyDictionary<TKey, TValue>, IThat<ReadOnlyDictio
params TValue[] expected)
where TKey : notnull
{
expected.ThrowIfNullOrEmpty();
ExpectationBuilder expectationBuilder = source.Get().ExpectationBuilder;
return new AndOrResult<ReadOnlyDictionary<TKey, TValue>, IThat<ReadOnlyDictionary<TKey, TValue>?>>(
expectationBuilder.AddConstraint((it, grammars) =>
Expand All @@ -56,6 +58,7 @@ public static AndOrResult<IReadOnlyDictionary<TKey, TValue>, IThat<IReadOnlyDict
this IThat<IReadOnlyDictionary<TKey, TValue>?> source,
params TValue[] unexpected)
{
unexpected.ThrowIfNullOrEmpty();
ExpectationBuilder expectationBuilder = source.Get().ExpectationBuilder;
return new AndOrResult<IReadOnlyDictionary<TKey, TValue>, IThat<IReadOnlyDictionary<TKey, TValue>?>>(
expectationBuilder.AddConstraint((it, grammars) =>
Expand All @@ -75,6 +78,7 @@ public static AndOrResult<ReadOnlyDictionary<TKey, TValue>, IThat<ReadOnlyDictio
params TValue[] unexpected)
where TKey : notnull
{
unexpected.ThrowIfNullOrEmpty();
ExpectationBuilder expectationBuilder = source.Get().ExpectationBuilder;
return new AndOrResult<ReadOnlyDictionary<TKey, TValue>, IThat<ReadOnlyDictionary<TKey, TValue>?>>(
expectationBuilder.AddConstraint((it, grammars) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,33 @@ async Task Act()
await That(Act).DoesNotThrow();
}

[Fact]
public async Task WhenExpectedIsEmpty_ShouldThrowArgumentException()
{
IDictionary<int, int> subject = ToDictionary([1, 2, 3,], [0, 0, 0,]);

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

await That(Act).Throws<ArgumentException>()
.WithParamName("expected").And
.WithMessage("The 'expected' collection cannot be empty.").AsPrefix();
}

[Fact]
public async Task WhenExpectedIsNull_ShouldThrowArgumentNullException()
{
IDictionary<int, int> subject = ToDictionary([1, 2, 3,], [0, 0, 0,]);
int[]? expected = null;

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

await That(Act).Throws<ArgumentNullException>()
.WithParamName("expected").And
.WithMessage("The expected cannot be null.").AsPrefix();
}

[Fact]
public async Task WhenOneKeyIsMissing_ShouldFail()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,33 @@ async Task Act()
await That(Act).DoesNotThrow();
}

[Fact]
public async Task WhenExpectedIsEmpty_ShouldThrowArgumentException()
{
IDictionary<int, int> subject = ToDictionary([1, 2, 3,], [41, 42, 43,]);

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

await That(Act).Throws<ArgumentException>()
.WithParamName("expected").And
.WithMessage("The 'expected' collection cannot be empty.").AsPrefix();
}

[Fact]
public async Task WhenExpectedIsNull_ShouldThrowArgumentNullException()
{
IDictionary<int, int> subject = ToDictionary([1, 2, 3,], [41, 42, 43,]);
int[]? expected = null;

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

await That(Act).Throws<ArgumentNullException>()
.WithParamName("expected").And
.WithMessage("The expected cannot be null.").AsPrefix();
}

[Fact]
public async Task WhenOneValueIsMissing_ShouldFail()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,33 @@ Expected that subject
but it was <null>
""");
}

[Fact]
public async Task WhenUnexpectedIsEmpty_ShouldThrowArgumentException()
{
IDictionary<int, int> subject = ToDictionary([1, 2, 3,], [0, 0, 0,]);

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

await That(Act).Throws<ArgumentException>()
.WithParamName("unexpected").And
.WithMessage("The 'unexpected' collection cannot be empty.").AsPrefix();
}

[Fact]
public async Task WhenUnexpectedIsNull_ShouldThrowArgumentNullException()
{
IDictionary<int, int> subject = ToDictionary([1, 2, 3,], [0, 0, 0,]);
int[]? unexpected = null;

async Task Act()
=> await That(subject).DoesNotContainKeys(unexpected!);

await That(Act).Throws<ArgumentNullException>()
.WithParamName("unexpected").And
.WithMessage("The unexpected cannot be null.").AsPrefix();
}
}

public sealed class NegatedTests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,33 @@ Expected that subject
but it was <null>
""");
}

[Fact]
public async Task WhenUnexpectedIsEmpty_ShouldThrowArgumentException()
{
IDictionary<int, int> subject = ToDictionary([1, 2, 3,], [41, 42, 43,]);

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

await That(Act).Throws<ArgumentException>()
.WithParamName("unexpected").And
.WithMessage("The 'unexpected' collection cannot be empty.").AsPrefix();
}

[Fact]
public async Task WhenUnexpectedIsNull_ShouldThrowArgumentNullException()
{
IDictionary<int, int> subject = ToDictionary([1, 2, 3,], [41, 42, 43,]);
int[]? unexpected = null;

async Task Act()
=> await That(subject).DoesNotContainValues(unexpected!);

await That(Act).Throws<ArgumentNullException>()
.WithParamName("unexpected").And
.WithMessage("The unexpected cannot be null.").AsPrefix();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,33 @@ async Task Act()
await That(Act).DoesNotThrow();
}

[Fact]
public async Task WhenExpectedIsEmpty_ShouldThrowArgumentException()
{
IReadOnlyDictionary<int, int> subject = ToDictionary([1, 2, 3,], [0, 0, 0,]);

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

await That(Act).Throws<ArgumentException>()
.WithParamName("expected").And
.WithMessage("The 'expected' collection cannot be empty.").AsPrefix();
}

[Fact]
public async Task WhenExpectedIsNull_ShouldThrowArgumentNullException()
{
IReadOnlyDictionary<int, int> subject = ToDictionary([1, 2, 3,], [0, 0, 0,]);
int[]? expected = null;

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

await That(Act).Throws<ArgumentNullException>()
.WithParamName("expected").And
.WithMessage("The expected cannot be null.").AsPrefix();
}

[Fact]
public async Task WhenOneKeyIsMissing_ShouldFail()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,33 @@ async Task Act()
await That(Act).DoesNotThrow();
}

[Fact]
public async Task WhenExpectedIsEmpty_ShouldThrowArgumentException()
{
IReadOnlyDictionary<int, int> subject = ToDictionary([1, 2, 3,], [41, 42, 43,]);

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

await That(Act).Throws<ArgumentException>()
.WithParamName("expected").And
.WithMessage("The 'expected' collection cannot be empty.").AsPrefix();
}

[Fact]
public async Task WhenExpectedIsNull_ShouldThrowArgumentNullException()
{
IReadOnlyDictionary<int, int> subject = ToDictionary([1, 2, 3,], [41, 42, 43,]);
int[]? expected = null;

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

await That(Act).Throws<ArgumentNullException>()
.WithParamName("expected").And
.WithMessage("The expected cannot be null.").AsPrefix();
}

[Fact]
public async Task WhenOneValueIsMissing_ShouldFail()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,33 @@ Expected that subject
but it was <null>
""");
}

[Fact]
public async Task WhenUnexpectedIsEmpty_ShouldThrowArgumentException()
{
IReadOnlyDictionary<int, int> subject = ToDictionary([1, 2, 3,], [0, 0, 0,]);

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

await That(Act).Throws<ArgumentException>()
.WithParamName("unexpected").And
.WithMessage("The 'unexpected' collection cannot be empty.").AsPrefix();
}

[Fact]
public async Task WhenUnexpectedIsNull_ShouldThrowArgumentNullException()
{
IReadOnlyDictionary<int, int> subject = ToDictionary([1, 2, 3,], [0, 0, 0,]);
int[]? unexpected = null;

async Task Act()
=> await That(subject).DoesNotContainKeys(unexpected!);

await That(Act).Throws<ArgumentNullException>()
.WithParamName("unexpected").And
.WithMessage("The unexpected cannot be null.").AsPrefix();
}
}

public sealed class NegatedTests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,33 @@ Expected that subject
but it was <null>
""");
}

[Fact]
public async Task WhenUnexpectedIsEmpty_ShouldThrowArgumentException()
{
IReadOnlyDictionary<int, int> subject = ToDictionary([1, 2, 3,], [41, 42, 43,]);

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

await That(Act).Throws<ArgumentException>()
.WithParamName("unexpected").And
.WithMessage("The 'unexpected' collection cannot be empty.").AsPrefix();
}

[Fact]
public async Task WhenUnexpectedIsNull_ShouldThrowArgumentNullException()
{
IReadOnlyDictionary<int, int> subject = ToDictionary([1, 2, 3,], [41, 42, 43,]);
int[]? unexpected = null;

async Task Act()
=> await That(subject).DoesNotContainValues(unexpected!);

await That(Act).Throws<ArgumentNullException>()
.WithParamName("unexpected").And
.WithMessage("The unexpected cannot be null.").AsPrefix();
}
}
}
}