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 @@ -10,7 +10,7 @@ public async Task Fails_For_Code_With_Other_Exceptions()
{
var expectedMessage = """
Expected to throw exactly CustomException
but threw TUnit.Assertions.Tests.Assertions.Delegates.Throws+OtherException
but threw OtherException

at Assert.That(action).ThrowsExactly<CustomException>()
""".NormalizeLineEndings();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public async Task Fails_For_Code_With_Other_Exceptions()
{
var expectedMessage = """
Expected to throw CustomException
but threw TUnit.Assertions.Tests.Assertions.Delegates.Throws+OtherException
but threw OtherException

at Assert.That(action).Throws<CustomException>()
""".NormalizeLineEndings();
Expand All @@ -29,7 +29,7 @@ public async Task Fails_For_Code_With_Supertype_Exceptions()
{
var expectedMessage = """
Expected to throw SubCustomException
but threw TUnit.Assertions.Tests.Assertions.Delegates.Throws+CustomException
but threw CustomException

at Assert.That(action).Throws<SubCustomException>()
""".NormalizeLineEndings();
Expand Down
8 changes: 4 additions & 4 deletions TUnit.Assertions.Tests/AsyncEnumerableAssertionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public async Task Test_AsyncEnumerable_HasCount_Fails()
var action = async () => await Assert.That(items).HasCount(5);

var exception = await Assert.That(action).Throws<AssertionException>();
await Assert.That(exception.Message).Contains("found 3 items");
await Assert.That(exception.Message).Contains("received 3 items");
}

// Contains tests
Expand All @@ -72,7 +72,7 @@ public async Task Test_AsyncEnumerable_Contains_Fails()
var action = async () => await Assert.That(items).Contains(99);

var exception = await Assert.That(action).Throws<AssertionException>();
await Assert.That(exception.Message).Contains("item 99 was not found");
await Assert.That(exception.Message).Contains("99 was not found in the collection");
}

// DoesNotContain tests
Expand All @@ -90,7 +90,7 @@ public async Task Test_AsyncEnumerable_DoesNotContain_Fails()
var action = async () => await Assert.That(items).DoesNotContain(5);

var exception = await Assert.That(action).Throws<AssertionException>();
await Assert.That(exception.Message).Contains("item 5 was found");
await Assert.That(exception.Message).Contains("5 was found in the collection");
}

// All tests
Expand Down Expand Up @@ -157,7 +157,7 @@ public async Task Test_AsyncEnumerable_Null_Fails()
var action = async () => await Assert.That(items!).IsEmpty();

var exception = await Assert.That(action).Throws<AssertionException>();
await Assert.That(exception.Message).Contains("was null");
await Assert.That(exception.Message).Contains("received null");
}

// String async enumerable
Expand Down
4 changes: 2 additions & 2 deletions TUnit.Assertions.Tests/Bugs/Tests2145.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ public async Task TestFailMessage()

var expectedMessage = """
Expected to be equal to "world"
but found "hello"
but received "hello"

at Assert.That(val).IsEqualTo("world")

Expected to be equal to "World"
but found "hello"
but received "hello"

at Assert.That(val).IsEqualTo("World")
""";
Expand Down
8 changes: 4 additions & 4 deletions TUnit.Assertions.Tests/Helpers/StringDifferenceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public async Task Works_For_Empty_String_As_Actual()
{
var expectedMessage = """
Expected to be equal to "some text"
but found ""
but received ""

at Assert.That(actual).IsEqualTo(expected)
""".NormalizeLineEndings();
Expand All @@ -26,7 +26,7 @@ public async Task Works_For_Empty_String_As_Expected()
{
var expectedMessage = """
Expected to be equal to ""
but found "actual text"
but received "actual text"

at Assert.That(actual).IsEqualTo(expected)
""".NormalizeLineEndings();
Expand All @@ -45,7 +45,7 @@ public async Task Works_When_Actual_Starts_With_Expected()
{
var expectedMessage = """
Expected to be equal to "some text"
but found "some"
but received "some"

at Assert.That(actual).IsEqualTo(expected)
""".NormalizeLineEndings();
Expand All @@ -64,7 +64,7 @@ public async Task Works_When_Expected_Starts_With_Actual()
{
var expectedMessage = """
Expected to be equal to "some"
but found "some text"
but received "some text"

at Assert.That(actual).IsEqualTo(expected)
""".NormalizeLineEndings();
Expand Down
2 changes: 1 addition & 1 deletion TUnit.Assertions.Tests/MemberCollectionAssertionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public async Task Member_Array_HasCount_Fails()
await Assert.That(obj).Member(x => x.Tags, tags => tags.HasCount(5)));

await Assert.That(exception.Message).Contains("to have count 5");
await Assert.That(exception.Message).Contains("but found 2");
await Assert.That(exception.Message).Contains("but received 2");
}

[Test]
Expand Down
2 changes: 1 addition & 1 deletion TUnit.Assertions.Tests/Old/StringEqualsAssertionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ Volutpat vero est ea clita clita magna dolor nulla ipsum aliquyam nonumy.
var exception = await TUnitAssert.ThrowsAsync<TUnitAssertionException>(async () => await TUnitAssert.That(value1).IsEqualTo(value2));

var expectedMessage = $"Expected to be equal to \"Lorem ipsum dolor sit amet diam duo amet sea rebum. Et voluptua ex voluptua no praesent diam eu se…\"{Environment.NewLine}" +
$"but found \"Lorem ipsum dolor sit amet diam duo amet sea rebum. Et voluptua ex voluptua no praesent diam eu se…\" which differs at index 556:{Environment.NewLine}" +
$"but received \"Lorem ipsum dolor sit amet diam duo amet sea rebum. Et voluptua ex voluptua no praesent diam eu se…\" which differs at index 556:{Environment.NewLine}" +
$" ↓{Environment.NewLine}" +
$" \"Consequat odio ea veniam. Amet enim in gubergren s…\"{Environment.NewLine}" +
$" \"Consequat odio ea veniam! Amet enim in gubergren s…\"{Environment.NewLine}" +
Expand Down
18 changes: 9 additions & 9 deletions TUnit.Assertions.Tests/Old/StringRegexAssertionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public async Task Matches_WithInvalidPattern_StringPattern_Throws(Type exception

await TUnitAssert.That(exception!.Message.NormalizeLineEndings()).IsEqualTo(
$"""
Expected text match pattern
Expected to match pattern
but The regex "^\d+$" does not match with "{text}"

at Assert.That(text).Matches(pattern)
Expand All @@ -83,7 +83,7 @@ public async Task Matches_WithInvalidPattern_RegexPattern_Throws(Type exceptionT

await TUnitAssert.That(exception!.Message.NormalizeLineEndings()).IsEqualTo(
$"""
Expected text match pattern
Expected to match pattern
but The regex "^\d+$" does not match with "{text}"

at Assert.That(text).Matches(pattern)
Expand Down Expand Up @@ -112,7 +112,7 @@ public async Task Matches_WithInvalidPattern_GeneratedRegexPattern_Throws(Type e

await TUnitAssert.That(exception!.Message.NormalizeLineEndings()).IsEqualTo(
$"""
Expected text match regex
Expected to match regex
but The regex "^\d+$" does not match with "Hello123World"

at Assert.That(text).Matches(regex)
Expand Down Expand Up @@ -194,8 +194,8 @@ public async Task DoesNotMatch_WithInvalidPattern_StringPattern_Throws(Type exce

await TUnitAssert.That(exception!.Message.NormalizeLineEndings()).IsEqualTo(
$"""
Expected text to not match with pattern
but The regex "^\d+$" matches with "{text}"
Expected to not match pattern
but received "{text}" which matches the pattern "^\d+$"

at Assert.That(text).DoesNotMatch(pattern)
""".NormalizeLineEndings()
Expand All @@ -219,8 +219,8 @@ public async Task DoesNotMatch_WithInvalidPattern_RegexPattern_Throws(Type excep

await TUnitAssert.That(exception!.Message.NormalizeLineEndings()).IsEqualTo(
$"""
Expected text to not match with pattern
but The regex "^\d+$" matches with "{text}"
Expected to not match pattern
but received "{text}" which matches the pattern "^\d+$"

at Assert.That(text).DoesNotMatch(pattern)
""".NormalizeLineEndings()
Expand Down Expand Up @@ -248,8 +248,8 @@ public async Task DoesNotMatch_WithInvalidPattern_GeneratedRegexPattern_Throws(T

await TUnitAssert.That(exception!.Message.NormalizeLineEndings()).IsEqualTo(
$"""
Expected text to not match with regex
but The regex "^\d+$" matches with "{text}"
Expected to not match regex
but received "{text}" which matches the pattern "^\d+$"

at Assert.That(text).DoesNotMatch(regex)
""".NormalizeLineEndings()
Expand Down
8 changes: 4 additions & 4 deletions TUnit.Assertions.Tests/SatisfiesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ await Assert.That(myModel)
).Throws<AssertionException>()
.WithMessageMatching("""
*to satisfy*
*found "Hello"*
*received "Hello"*
""");
}

Expand Down Expand Up @@ -125,7 +125,7 @@ await Assert.That(myModel)
.WithMessageMatching(
"""
*to satisfy*
*found "Baz"*
*received "Baz"*
"""
);
}
Expand All @@ -144,7 +144,7 @@ await Assert.That(myModel)
).Throws<AssertionException>()
.WithMessageMatching("""
*to satisfy*
*found "Hello"*
*received "Hello"*
""");
}

Expand Down Expand Up @@ -176,7 +176,7 @@ await Assert.That(myModel)
).Throws<AssertionException>()
.WithMessageMatching(
"""
*found "Blah"*
*received "Blah"*
"""
);
}
Expand Down
4 changes: 2 additions & 2 deletions TUnit.Assertions.Tests/ThrowInDelegateValueAssertionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public async Task ThrowInDelegateValueAssertion_ReturnsExpectedErrorMessage()
{
var expectedContains = """
Expected to be equal to True
but threw System.Exception
but threw Exception
""".NormalizeLineEndings();
var assertion = async () => await Assert.That(() =>
{
Expand All @@ -31,7 +31,7 @@ public async Task ThrowInDelegateValueAssertion_RespectsCaseInsensitiveMessage()

await Assert.That(assertion)
.Throws<AssertionException>()
.WithMessageContaining("SYSTEM.EXCEPTION", StringComparison.OrdinalIgnoreCase);
.WithMessageContaining("EXCEPTION", StringComparison.OrdinalIgnoreCase);
}

[Test]
Expand Down
10 changes: 5 additions & 5 deletions TUnit.Assertions/Collections/CollectionChecks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static AssertionResult CheckIsNotEmpty<TItem>(ICollectionAdapter<TItem> a
return AssertionResult.Passed;
}

return AssertionResult.Failed("it was empty");
return AssertionResult.Failed("received empty collection");
}

/// <summary>
Expand Down Expand Up @@ -117,7 +117,7 @@ public static AssertionResult CheckDoesNotContainPredicate<TItem>(
{
if (predicate(item))
{
return AssertionResult.Failed("found item matching predicate");
return AssertionResult.Failed("received item matching predicate");
}
}

Expand Down Expand Up @@ -157,7 +157,7 @@ public static AssertionResult CheckCount<TItem>(ICollectionAdapter<TItem> adapte
return AssertionResult.Passed;
}

return AssertionResult.Failed($"found {actual}");
return AssertionResult.Failed($"received {actual}");
}

/// <summary>
Expand All @@ -171,7 +171,7 @@ public static AssertionResult CheckHasSingleItem<TItem>(ICollectionAdapter<TItem
return AssertionResult.Passed;
}

return AssertionResult.Failed($"it had {count} item(s)");
return AssertionResult.Failed($"received {count} item(s)");
}

/// <summary>
Expand Down Expand Up @@ -622,6 +622,6 @@ public static AssertionResult CheckSetEquals<TItem>(
return AssertionResult.Passed;
}

return AssertionResult.Failed("the set does not equal the specified collection");
return AssertionResult.Failed("received set does not equal the specified collection");
}
}
8 changes: 4 additions & 4 deletions TUnit.Assertions/Conditions/AsyncEnumerableAssertions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ protected override async Task<AssertionResult> CheckAsync(EvaluationMetadata<IAs

if (metadata.Value == null)
{
return AssertionResult.Failed("was null");
return AssertionResult.Failed("received null");
}

// Materialize the async enumerable
Expand Down Expand Up @@ -105,7 +105,7 @@ protected override AssertionResult CheckMaterialized(List<TItem> items)
{
return items.Count == _expected
? AssertionResult.Passed
: AssertionResult.Failed($"found {items.Count} items");
: AssertionResult.Failed($"received {items.Count} items");
}

protected override string GetExpectation() => $"to have {_expected} items";
Expand Down Expand Up @@ -141,12 +141,12 @@ protected override AssertionResult CheckMaterialized(List<TItem> items)
{
return contains
? AssertionResult.Passed
: AssertionResult.Failed($"item {_expected} was not found");
: AssertionResult.Failed($"{_expected} was not found in the collection");
}
else
{
return contains
? AssertionResult.Failed($"item {_expected} was found")
? AssertionResult.Failed($"{_expected} was found in the collection")
: AssertionResult.Passed;
}
}
Expand Down
4 changes: 2 additions & 2 deletions TUnit.Assertions/Conditions/BetweenAssertion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ protected override Task<AssertionResult> CheckAsync(EvaluationMetadata<TValue> m

if (value == null)
{
return Task.FromResult(AssertionResult.Failed("value is null"));
return Task.FromResult(AssertionResult.Failed("received null"));
}

var minComparison = value.CompareTo(_minimum);
Expand All @@ -92,7 +92,7 @@ protected override Task<AssertionResult> CheckAsync(EvaluationMetadata<TValue> m
return AssertionResult._passedTask;
}

return Task.FromResult(AssertionResult.Failed($"found {value}"));
return Task.FromResult(AssertionResult.Failed($"received {value}"));
}

protected override string GetExpectation()
Expand Down
2 changes: 1 addition & 1 deletion TUnit.Assertions/Conditions/CollectionCountSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ protected override async Task<AssertionResult> CheckAsync(EvaluationMetadata<TCo
return AssertionResult.Passed;
}

return AssertionResult.Failed($"found {_actualCount}");
return AssertionResult.Failed($"received {_actualCount}");
}

protected override string GetExpectation()
Expand Down
6 changes: 3 additions & 3 deletions TUnit.Assertions/Conditions/EqualsAssertion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ protected override Task<AssertionResult> CheckAsync(EvaluationMetadata<TValue> m

if (exception != null)
{
return Task.FromResult(AssertionResult.Failed($"threw {exception.GetType().FullName}"));
return Task.FromResult(AssertionResult.Failed($"threw {exception.GetType().Name}"));
}

// Deep comparison with ignored types
Expand All @@ -92,7 +92,7 @@ protected override Task<AssertionResult> CheckAsync(EvaluationMetadata<TValue> m
return AssertionResult._passedTask;
}

return Task.FromResult(AssertionResult.Failed(result.Message ?? $"found {value}"));
return Task.FromResult(AssertionResult.Failed(result.Message ?? $"received {value}"));
}

// Standard equality comparison
Expand All @@ -103,7 +103,7 @@ protected override Task<AssertionResult> CheckAsync(EvaluationMetadata<TValue> m
return AssertionResult._passedTask;
}

return Task.FromResult(AssertionResult.Failed($"found {value}"));
return Task.FromResult(AssertionResult.Failed($"received {value}"));
}

[UnconditionalSuppressMessage("Trimming", "IL2070", Justification = "Deep comparison requires reflection access to all public properties and fields of runtime types")]
Expand Down
Loading
Loading