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 @@ -180,9 +180,10 @@ private static void ReportThrowsFailed<TException>(

string expectedTypeLabel = isStrictType ? expectedTypeFullName : $"{expectedTypeFullName} (or derived)";

// The "actual exception:" line is already prefixed with the exception type name, so we don't emit a
// separate "actual type:" line to avoid duplicating that information.
EvidenceBlock evidence = EvidenceBlock.Create()
.AddLine("expected type:", expectedTypeLabel)
.AddLine("actual type:", actualTypeFullName)
.AddLine("actual exception:", $"{actualTypeFullName}: {actualException.Message}");

message = new StructuredAssertionMessage(summary)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ public void ThrowsAsync_WhenExceptionIsNotExpectedType_ShouldThrow()
Assertion failed. Expected exception of type ArgumentException (or derived) but caught Exception.

expected type: System.ArgumentException (or derived)
actual type: System.Exception
actual exception: System.Exception: Exception of type 'System.Exception' was thrown.

Assert.ThrowsAsync<ArgumentException>(() => throw new Exception())
Expand All @@ -93,7 +92,6 @@ public void ThrowsExactlyAsync_WhenExceptionIsDerivedFromExpectedType_ShouldThro
Assertion failed. Expected exception of exact type ArgumentException but caught ArgumentNullException.

expected type: System.ArgumentException
actual type: System.ArgumentNullException
actual exception: System.ArgumentNullException: Value cannot be null.

Assert.ThrowsExactlyAsync<ArgumentException>(() => throw new ArgumentNullException())
Expand Down Expand Up @@ -152,7 +150,6 @@ Assertion failed. Expected exception of type ArgumentNullException (or derived)
message constructed via builder.

expected type: System.ArgumentNullException (or derived)
actual type: System.ArgumentOutOfRangeException
actual exception: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'MyParamNameHere')

Assert.Throws<ArgumentNullException>(() => throw new ArgumentOutOfRangeException("MyParamNameHere"))
Expand All @@ -162,7 +159,6 @@ Assertion failed. Expected exception of type ArgumentNullException (or derived)
message constructed via builder.

expected type: System.ArgumentNullException (or derived)
actual type: System.ArgumentOutOfRangeException
actual exception: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: MyParamNameHere

Expand Down Expand Up @@ -226,7 +222,6 @@ Assertion failed. Expected exception of exact type ArgumentNullException but cau
message constructed via builder.

expected type: System.ArgumentNullException
actual type: System.ArgumentOutOfRangeException
actual exception: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'MyParamNameHere')

Assert.ThrowsExactly<ArgumentNullException>(() => throw new ArgumentOutOfRangeException("MyParamNameHere"))
Expand All @@ -236,7 +231,6 @@ Assertion failed. Expected exception of exact type ArgumentNullException but cau
message constructed via builder.

expected type: System.ArgumentNullException
actual type: System.ArgumentOutOfRangeException
actual exception: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: MyParamNameHere

Expand Down Expand Up @@ -300,7 +294,6 @@ Assertion failed. Expected exception of type ArgumentNullException (or derived)
message constructed via builder.

expected type: System.ArgumentNullException (or derived)
actual type: System.ArgumentOutOfRangeException
actual exception: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'MyParamNameHere')

Assert.ThrowsAsync<ArgumentNullException>(() => Task.FromException(new ArgumentOutOfRangeException("MyParamNameHere")))
Expand All @@ -310,7 +303,6 @@ Assertion failed. Expected exception of type ArgumentNullException (or derived)
message constructed via builder.

expected type: System.ArgumentNullException (or derived)
actual type: System.ArgumentOutOfRangeException
actual exception: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: MyParamNameHere

Expand Down Expand Up @@ -374,7 +366,6 @@ Assertion failed. Expected exception of exact type ArgumentNullException but cau
message constructed via builder.

expected type: System.ArgumentNullException
actual type: System.ArgumentOutOfRangeException
actual exception: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'MyParamNameHere')

Assert.ThrowsExactlyAsync<ArgumentNullException>(() => Task.FromException(new ArgumentOutOfRangeException("MyParamNameHere")))
Expand All @@ -384,7 +375,6 @@ Assertion failed. Expected exception of exact type ArgumentNullException but cau
message constructed via builder.

expected type: System.ArgumentNullException
actual type: System.ArgumentOutOfRangeException
actual exception: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: MyParamNameHere

Expand Down Expand Up @@ -436,7 +426,6 @@ public void Throws_WhenExceptionMessageContainsNewline_ContinuationLinesAreInden
Assertion failed. Expected exception of type ArgumentException (or derived) but caught InvalidOperationException.

expected type: System.ArgumentException (or derived)
actual type: System.InvalidOperationException
actual exception: System.InvalidOperationException: line1
line2

Expand All @@ -461,7 +450,6 @@ static void Action() => Assert.Throws<ArgumentException>(() =>
Assertion failed. Expected exception of type ArgumentException (or derived) but caught InvalidOperationException.

expected type: System.ArgumentException (or derived)
actual type: System.InvalidOperationException
actual exception: System.InvalidOperationException: oops

Assert.Throws<ArgumentException>(<action>)
Expand All @@ -481,7 +469,6 @@ public void Throws_WhenExpectedTypeIsGeneric_RendersFriendlyTypeName()
Assertion failed. Expected exception of type ThrowsTestGenericException<Int32> (or derived) but caught InvalidOperationException.

expected type: Microsoft.VisualStudio.TestPlatform.TestFramework.UnitTests.ThrowsTestGenericException<System.Int32> (or derived)
actual type: System.InvalidOperationException
actual exception: System.InvalidOperationException: oops

Assert.Throws<ThrowsTestGenericException<Int32>>(() => throw new InvalidOperationException("oops"))
Expand Down
Loading