Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
024a2ca
feat: implement IAsyncDiscoveryInitializer and related classes for im…
thomhurst Dec 7, 2025
7cdc0fc
feat: implement IAsyncDiscoveryInitializer and related classes for im…
thomhurst Dec 7, 2025
bebb3e2
feat: implement IAsyncDiscoveryInitializer and related classes for im…
thomhurst Dec 7, 2025
0041ee5
feat: implement IAsyncDiscoveryInitializer and related classes for im…
thomhurst Dec 7, 2025
8e97f35
feat: implement IAsyncDiscoveryInitializer and related classes for im…
thomhurst Dec 7, 2025
07b2215
feat: implement IAsyncDiscoveryInitializer and related classes for im…
thomhurst Dec 7, 2025
8589baa
feat: implement IAsyncDiscoveryInitializer and related classes for im…
thomhurst Dec 7, 2025
5c78262
feat: implement IAsyncDiscoveryInitializer and related classes for im…
thomhurst Dec 7, 2025
579cd75
feat: implement IAsyncDiscoveryInitializer and related classes for im…
thomhurst Dec 7, 2025
8c661b3
feat: implement IAsyncDiscoveryInitializer and related classes for im…
thomhurst Dec 7, 2025
8030e42
feat: implement IAsyncDiscoveryInitializer and related classes for im…
thomhurst Dec 7, 2025
1646680
feat: enhance type handling and object tracking with custom primitive…
thomhurst Dec 7, 2025
851e21c
feat: improve disposal callback registration logic to handle untracke…
thomhurst Dec 7, 2025
f89adb8
feat: change visibility of object graph related classes and interface…
thomhurst Dec 7, 2025
a1938e3
feat: implement IAsyncDiscoveryInitializer and related classes for im…
thomhurst Dec 7, 2025
9efbd55
feat: skip PlaceholderInstance during data source class resolution fo…
thomhurst Dec 7, 2025
da86e46
fix: normalize line endings in exception message assertions for consi…
thomhurst Dec 7, 2025
ca3065f
fix: normalize line endings in exception messages for consistency acr…
thomhurst Dec 7, 2025
2799dd7
fix: remove premature cache removal for shared data sources
thomhurst Dec 7, 2025
ff2e57e
feat: enable parallel initialization of tracked objects during test e…
thomhurst Dec 7, 2025
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
6 changes: 3 additions & 3 deletions TUnit.Assertions.Tests/AssertConditions/BecauseTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace TUnit.Assertions.Tests.AssertConditions;
namespace TUnit.Assertions.Tests.AssertConditions;

public class BecauseTests
{
Expand Down Expand Up @@ -68,7 +68,7 @@ at Assert.That(variable).IsFalse()
};

var exception = await Assert.ThrowsAsync<AssertionException>(action);
await Assert.That(exception.Message).IsEqualTo(expectedMessage);
await Assert.That(exception.Message.NormalizeLineEndings()).IsEqualTo(expectedMessage.NormalizeLineEndings());
}

[Test]
Expand All @@ -91,7 +91,7 @@ await Assert.That(variable).IsTrue().Because(because)
};

var exception = await Assert.ThrowsAsync<AssertionException>(action);
await Assert.That(exception.Message.NormalizeLineEndings()).IsEqualTo(expectedMessage);
await Assert.That(exception.Message.NormalizeLineEndings()).IsEqualTo(expectedMessage.NormalizeLineEndings());
}

[Test]
Expand Down
27 changes: 14 additions & 13 deletions TUnit.Assertions.Tests/Assertions/Delegates/Throws.ExactlyTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ public async Task Fails_For_Code_With_Other_Exceptions()
but threw TUnit.Assertions.Tests.Assertions.Delegates.Throws+OtherException

at Assert.That(action).ThrowsExactly<CustomException>()
""";
""".NormalizeLineEndings();
Exception exception = CreateOtherException();
Action action = () => throw exception;

var sut = async ()
=> await Assert.That(action).ThrowsExactly<CustomException>();

await Assert.That(sut).ThrowsException()
.WithMessage(expectedMessage);
var thrownException = await Assert.That(sut).ThrowsException();
await Assert.That(thrownException.Message.NormalizeLineEndings()).IsEqualTo(expectedMessage);
}

[Test]
Expand All @@ -32,15 +32,15 @@ public async Task Fails_For_Code_With_Subtype_Exceptions()
but wrong exception type: SubCustomException instead of exactly CustomException

at Assert.That(action).ThrowsExactly<CustomException>()
""";
""".NormalizeLineEndings();
Exception exception = CreateSubCustomException();
Action action = () => throw exception;

var sut = async ()
=> await Assert.That(action).ThrowsExactly<CustomException>();

await Assert.That(sut).ThrowsException()
.WithMessage(expectedMessage);
var thrownException = await Assert.That(sut).ThrowsException();
await Assert.That(thrownException.Message.NormalizeLineEndings()).IsEqualTo(expectedMessage);
}

[Test]
Expand All @@ -51,14 +51,14 @@ public async Task Fails_For_Code_Without_Exceptions()
but no exception was thrown

at Assert.That(action).ThrowsExactly<CustomException>()
""";
""".NormalizeLineEndings();
var action = () => { };

var sut = async ()
=> await Assert.That(action).ThrowsExactly<CustomException>();

await Assert.That(sut).ThrowsException()
.WithMessage(expectedMessage);
var thrownException = await Assert.That(sut).ThrowsException();
await Assert.That(thrownException.Message.NormalizeLineEndings()).IsEqualTo(expectedMessage);
}

[Test]
Expand Down Expand Up @@ -117,10 +117,11 @@ public async Task Conversion_To_Value_Assertion_Builder_On_Casted_Exception_Type
await Assert.That((object)ex).IsAssignableTo<CustomException>();
});

await Assert.That(assertionException).HasMessageStartingWith("""
Expected to throw exactly Exception
but wrong exception type: CustomException instead of exactly Exception
""");
var expectedPrefix = """
Expected to throw exactly Exception
but wrong exception type: CustomException instead of exactly Exception
""".NormalizeLineEndings();
await Assert.That(assertionException.Message.NormalizeLineEndings()).StartsWith(expectedPrefix);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ public async Task Fails_For_Code_Without_Exceptions()
but no exception was thrown

at Assert.That(action).ThrowsException()
""";
""".NormalizeLineEndings();
var action = () => { };

var sut = async ()
=> await Assert.That(action).ThrowsException();

await Assert.That(sut).ThrowsException()
.WithMessage(expectedMessage);
var thrownException = await Assert.That(sut).ThrowsException();
await Assert.That(thrownException.Message.NormalizeLineEndings()).IsEqualTo(expectedMessage);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ public async Task Fails_For_Code_With_Exceptions()
but threw TUnit.Assertions.Tests.Assertions.Delegates.Throws+CustomException: {nameof(Fails_For_Code_With_Exceptions)}

at Assert.That(action).ThrowsNothing()
""";
""".NormalizeLineEndings();
Exception exception = CreateCustomException();
Action action = () => throw exception;

var sut = async ()
=> await Assert.That(action).ThrowsNothing();

await Assert.That(sut).ThrowsException()
.WithMessage(expectedMessage);
var thrownException = await Assert.That(sut).ThrowsException();
await Assert.That(thrownException.Message.NormalizeLineEndings()).IsEqualTo(expectedMessage);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ public async Task Fails_For_Code_With_Other_Exceptions()
but threw TUnit.Assertions.Tests.Assertions.Delegates.Throws+OtherException

at Assert.That(action).Throws<CustomException>()
""";
""".NormalizeLineEndings();
Exception exception = CreateOtherException();
Action action = () => throw exception;

var sut = async ()
=> await Assert.That(action).Throws<CustomException>();

await Assert.That(sut).ThrowsException()
.WithMessage(expectedMessage);
var thrownException = await Assert.That(sut).ThrowsException();
await Assert.That(thrownException.Message.NormalizeLineEndings()).IsEqualTo(expectedMessage);
}

[Test]
Expand All @@ -32,15 +32,15 @@ public async Task Fails_For_Code_With_Supertype_Exceptions()
but threw TUnit.Assertions.Tests.Assertions.Delegates.Throws+CustomException

at Assert.That(action).Throws<SubCustomException>()
""";
""".NormalizeLineEndings();
Exception exception = CreateCustomException();
Action action = () => throw exception;

var sut = async ()
=> await Assert.That(action).Throws<SubCustomException>();

await Assert.That(sut).ThrowsException()
.WithMessage(expectedMessage);
var thrownException = await Assert.That(sut).ThrowsException();
await Assert.That(thrownException.Message.NormalizeLineEndings()).IsEqualTo(expectedMessage);
}

[Test]
Expand All @@ -51,14 +51,14 @@ public async Task Fails_For_Code_Without_Exceptions()
but no exception was thrown

at Assert.That(action).Throws<CustomException>()
""";
""".NormalizeLineEndings();
var action = () => { };

var sut = async ()
=> await Assert.That(action).Throws<CustomException>();

await Assert.That(sut).ThrowsException()
.WithMessage(expectedMessage);
var thrownException = await Assert.That(sut).ThrowsException();
await Assert.That(thrownException.Message.NormalizeLineEndings()).IsEqualTo(expectedMessage);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Expected exception message to equal "bar"
but exception message was "some different inner message"

at Assert.That(action).ThrowsException().WithInnerException().WithMessage("bar")
""";
""".NormalizeLineEndings();
Exception exception = CreateCustomException(outerMessage,
CreateCustomException("some different inner message"));
Action action = () => throw exception;
Expand All @@ -24,8 +24,8 @@ at Assert.That(action).ThrowsException().WithInnerException().WithMessage("bar")
=> await Assert.That(action).ThrowsException()
.WithInnerException().WithMessage(expectedInnerMessage);

await Assert.That(sut).ThrowsException()
.WithMessage(expectedMessage);
var thrownException = await Assert.That(sut).ThrowsException();
await Assert.That(thrownException.Message.NormalizeLineEndings()).IsEqualTo(expectedMessage);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ Expected exception message to match pattern "bar"
but exception message "foo" does not match pattern "bar"

at Assert.That(action).ThrowsExactly<CustomException>().WithMessageMatching("bar")
""";
""".NormalizeLineEndings();
Exception exception = CreateCustomException(message1);
Action action = () => throw exception;

var sut = async ()
=> await Assert.That(action).ThrowsExactly<CustomException>().WithMessageMatching(message2);

await Assert.That(sut).ThrowsException()
.WithMessage(expectedMessage);
var thrownException = await Assert.That(sut).ThrowsException();
await Assert.That(thrownException.Message.NormalizeLineEndings()).IsEqualTo(expectedMessage);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ Expected exception message to equal "bar"
but exception message was "foo"
at Assert.That(action).ThrowsExactly<CustomException>().WithMessage("bar")
""";
""".NormalizeLineEndings();
Exception exception = CreateCustomException(message1);
Action action = () => throw exception;

var sut = async ()
=> await Assert.That(action).ThrowsExactly<CustomException>().WithMessage(message2);

await Assert.That(sut).ThrowsException()
.WithMessage(expectedMessage);
var thrownException = await Assert.That(sut).ThrowsException();
await Assert.That(thrownException.Message.NormalizeLineEndings()).IsEqualTo(expectedMessage);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ public async Task Fails_For_Different_Parameter_Name()
but ArgumentException parameter name was "foo"

at Assert.That(action).ThrowsExactly<ArgumentException>().WithParameterName("bar")
""";
""".NormalizeLineEndings();
ArgumentException exception = new(string.Empty, paramName1);
Action action = () => throw exception;

var sut = async ()
=> await Assert.That(action).ThrowsExactly<ArgumentException>().WithParameterName(paramName2);

await Assert.That(sut).ThrowsException()
.WithMessage(expectedMessage);
var thrownException = await Assert.That(sut).ThrowsException();
await Assert.That(thrownException.Message.NormalizeLineEndings()).IsEqualTo(expectedMessage);
}

[Test]
Expand Down
14 changes: 8 additions & 6 deletions TUnit.Assertions.Tests/Bugs/Tests2117.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ at Assert.That(a).IsEquivalentTo(b)
""")]
public async Task IsEquivalent_Fail(int[] a, int[] b, CollectionOrdering? collectionOrdering, string expectedError)
{
await Assert.That(async () =>
var exception = await Assert.That(async () =>
await (collectionOrdering is null
? Assert.That(a).IsEquivalentTo(b)
: Assert.That(a).IsEquivalentTo(b, collectionOrdering.Value))
).Throws<AssertionException>()
.WithMessage(expectedError);
).Throws<AssertionException>();

await Assert.That(exception.Message.NormalizeLineEndings()).IsEqualTo(expectedError.NormalizeLineEndings());
}

[Test]
Expand All @@ -60,11 +61,12 @@ at Assert.That(a).IsNotEquivalentTo(b)
""")]
public async Task IsNotEquivalent_Fail(int[] a, int[] b, CollectionOrdering? collectionOrdering, string expectedError)
{
await Assert.That(async () =>
var exception = await Assert.That(async () =>
await (collectionOrdering is null
? Assert.That(a).IsNotEquivalentTo(b)
: Assert.That(a).IsNotEquivalentTo(b, collectionOrdering.Value))
).Throws<AssertionException>()
.WithMessage(expectedError);
).Throws<AssertionException>();

await Assert.That(exception.Message.NormalizeLineEndings()).IsEqualTo(expectedError.NormalizeLineEndings());
}
}
24 changes: 12 additions & 12 deletions TUnit.Assertions.Tests/Helpers/StringDifferenceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ Expected to be equal to "some text"
but found ""

at Assert.That(actual).IsEqualTo(expected)
""";
""".NormalizeLineEndings();
var actual = "";
var expected = "some text";

var sut = async ()
=> await Assert.That(actual).IsEqualTo(expected);

await Assert.That(sut).ThrowsException()
.WithMessage(expectedMessage);
var exception = await Assert.That(sut).ThrowsException();
await Assert.That(exception.Message.NormalizeLineEndings()).IsEqualTo(expectedMessage);
}

[Test]
Expand All @@ -29,15 +29,15 @@ Expected to be equal to ""
but found "actual text"

at Assert.That(actual).IsEqualTo(expected)
""";
""".NormalizeLineEndings();
var actual = "actual text";
var expected = "";

var sut = async ()
=> await Assert.That(actual).IsEqualTo(expected);

await Assert.That(sut).ThrowsException()
.WithMessage(expectedMessage);
var exception = await Assert.That(sut).ThrowsException();
await Assert.That(exception.Message.NormalizeLineEndings()).IsEqualTo(expectedMessage);
}

[Test]
Expand All @@ -48,15 +48,15 @@ Expected to be equal to "some text"
but found "some"

at Assert.That(actual).IsEqualTo(expected)
""";
""".NormalizeLineEndings();
var actual = "some";
var expected = "some text";

var sut = async ()
=> await Assert.That(actual).IsEqualTo(expected);

await Assert.That(sut).ThrowsException()
.WithMessage(expectedMessage);
var exception = await Assert.That(sut).ThrowsException();
await Assert.That(exception.Message.NormalizeLineEndings()).IsEqualTo(expectedMessage);
}

[Test]
Expand All @@ -67,14 +67,14 @@ Expected to be equal to "some"
but found "some text"

at Assert.That(actual).IsEqualTo(expected)
""";
""".NormalizeLineEndings();
var actual = "some text";
var expected = "some";

var sut = async ()
=> await Assert.That(actual).IsEqualTo(expected);

await Assert.That(sut).ThrowsException()
.WithMessage(expectedMessage);
var exception = await Assert.That(sut).ThrowsException();
await Assert.That(exception.Message.NormalizeLineEndings()).IsEqualTo(expectedMessage);
}
}
Loading
Loading