Skip to content

Commit

Permalink
Replaced Obsolete attributes in WhenCalled<T> with doc comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mihnea Rădulescu authored and dtchepak committed Jun 2, 2024
1 parent 0c0d798 commit 2ce4d66
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/NSubstitute/Core/WhenCalled.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ namespace NSubstitute.Core;

public class WhenCalled<T>(ISubstitutionContext context, T substitute, Action<T> call, MatchArgs matchArgs)
{
private const string RecommendedThrowMethodToUseMessage =
"The recommended method to use is Throw().";

private readonly ICallRouter _callRouter = context.GetCallRouterFor(substitute!);
private readonly IThreadLocalContext _threadContext = context.ThreadContext;
private readonly IRouteFactory _routeFactory = context.RouteFactory;
Expand Down Expand Up @@ -77,21 +74,21 @@ public void Throw(Func<CallInfo, Exception> createException) =>
/// <summary>
/// Throws the specified exception when called.
/// </summary>
[Obsolete(RecommendedThrowMethodToUseMessage)]
/// Prefer <see cref="Throw(System.Exception)" /> for readability.
public void Throws(Exception exception) =>
Throw(exception);

/// <summary>
/// Throws an exception of the given type when called.
/// </summary>
[Obsolete(RecommendedThrowMethodToUseMessage)]
/// Prefer <see cref="Throw{TException}" /> for readability.
public TException Throws<TException>() where TException : Exception, new()
=> Throw<TException>();

/// <summary>
/// Throws an exception generated by the specified function when called.
/// </summary>
[Obsolete(RecommendedThrowMethodToUseMessage)]
/// Prefer <see cref="Throw(System.Func{CallInfo, System.Exception})" /> for readability.
public void Throws(Func<CallInfo, Exception> createException) =>
Throw(createException);
}

0 comments on commit 2ce4d66

Please sign in to comment.