Skip to content

Commit

Permalink
Increase test coverage for Exception.TargetSite (dotnet#50275)
Browse files Browse the repository at this point in the history
* Increase test coverage for Exception.TargetSite

* Apply suggestions from code review

Co-authored-by: Stephen Toub <stoub@microsoft.com>

Co-authored-by: Stephen Toub <stoub@microsoft.com>
  • Loading branch information
MichalStrehovsky and stephentoub committed Mar 29, 2021
1 parent 508df29 commit 21734a4
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/libraries/System.Runtime/tests/System/ExceptionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static void Exception_GetBaseException()
}

[Fact]
public static void Exception_TargetSite_Jit()
public static void Exception_TargetSite()
{
bool caught = false;

Expand All @@ -78,6 +78,32 @@ public static void Exception_TargetSite_Jit()

Assert.True(caught);
}

static void RethrowException()
{
try
{
ThrowException();
}
catch
{
throw;
}
}

[Fact]
public static void Exception_TargetSite_OtherMethod()
{
Exception ex = Assert.ThrowsAny<Exception>(() => ThrowException());
Assert.Equal(nameof(ThrowException), ex.TargetSite.Name);
}

[Fact]
public static void Exception_TargetSite_Rethrow()
{
Exception ex = Assert.ThrowsAny<Exception>(() => RethrowException());
Assert.Equal(nameof(ThrowException), ex.TargetSite.Name);
}

[Fact]
[ActiveIssue("https://github.com/mono/mono/issues/15140", TestRuntimes.Mono)]
Expand Down

0 comments on commit 21734a4

Please sign in to comment.