diff --git a/TUnit.Assertions/Assert.cs b/TUnit.Assertions/Assert.cs index 0338f45cd8..035b980661 100644 --- a/TUnit.Assertions/Assert.cs +++ b/TUnit.Assertions/Assert.cs @@ -1,6 +1,7 @@ using System.Collections; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; +using TUnit.Assertions.AssertConditions.Throws; using TUnit.Assertions.AssertionBuilders; using TUnit.Assertions.Extensions; using TUnit.Assertions.Helpers; @@ -8,53 +9,54 @@ namespace TUnit.Assertions; +[SuppressMessage("Usage", "TUnitAssertions0002:Assert statements must be awaited")] public static class Assert { public static ValueAssertionBuilder That(TActual value, [CallerArgumentExpression(nameof(value))] string? doNotPopulateThisValue = null) { return new ValueAssertionBuilder(value, doNotPopulateThisValue); } - + public static ValueAssertionBuilder> That(IEnumerable enumerable, [CallerArgumentExpression(nameof(enumerable))] string? doNotPopulateThisValue = null) { return new ValueAssertionBuilder>(new UnTypedEnumerableWrapper(enumerable), doNotPopulateThisValue); } - + public static DelegateAssertionBuilder That(Action value, [CallerArgumentExpression(nameof(value))] string? doNotPopulateThisValue = null) { return new DelegateAssertionBuilder(value, doNotPopulateThisValue); } - + public static ValueDelegateAssertionBuilder That(Func value, [CallerArgumentExpression(nameof(value))] string? doNotPopulateThisValue = null) { return new ValueDelegateAssertionBuilder(value, doNotPopulateThisValue); } - + public static AsyncDelegateAssertionBuilder That(Func value, [CallerArgumentExpression(nameof(value))] string? doNotPopulateThisValue = null) { return new AsyncDelegateAssertionBuilder(value, doNotPopulateThisValue); } - + public static AsyncValueDelegateAssertionBuilder That(Func> value, [CallerArgumentExpression(nameof(value))] string? doNotPopulateThisValue = null) { return new AsyncValueDelegateAssertionBuilder(value, doNotPopulateThisValue); } - + public static AsyncDelegateAssertionBuilder That(Task value, [CallerArgumentExpression(nameof(value))] string? doNotPopulateThisValue = null) { return new AsyncDelegateAssertionBuilder(async () => await value, doNotPopulateThisValue); } - + public static AsyncValueDelegateAssertionBuilder That(Task value, [CallerArgumentExpression(nameof(value))] string? doNotPopulateThisValue = null) { return new AsyncValueDelegateAssertionBuilder(async () => await value, doNotPopulateThisValue); } - + public static AsyncDelegateAssertionBuilder That(ValueTask value, [CallerArgumentExpression(nameof(value))] string? doNotPopulateThisValue = null) { return new AsyncDelegateAssertionBuilder(async () => await value, doNotPopulateThisValue); } - + public static AsyncValueDelegateAssertionBuilder That(ValueTask value, [CallerArgumentExpression(nameof(value))] string? doNotPopulateThisValue = null) { return new AsyncValueDelegateAssertionBuilder(async () => await value, doNotPopulateThisValue); @@ -65,87 +67,70 @@ public static IDisposable Multiple() return new AssertionScope(); } - public static Task ThrowsAsync(Func @delegate, + public static ThrowsException ThrowsAsync(Func @delegate, [CallerArgumentExpression(nameof(@delegate))] string? doNotPopulateThisValue = null) => ThrowsAsync(@delegate, doNotPopulateThisValue); - public static Task ThrowsAsync(Task @delegate, + public static ThrowsException ThrowsAsync(Task @delegate, [CallerArgumentExpression(nameof(@delegate))] string? doNotPopulateThisValue = null) => ThrowsAsync(async () => await @delegate, doNotPopulateThisValue); - - public static Task ThrowsAsync(ValueTask @delegate, + + public static ThrowsException ThrowsAsync(ValueTask @delegate, [CallerArgumentExpression(nameof(@delegate))] string? doNotPopulateThisValue = null) => ThrowsAsync(async () => await @delegate, doNotPopulateThisValue); - - public static Task ThrowsAsync(Task @delegate, + + public static ThrowsException ThrowsAsync(Task @delegate, [CallerArgumentExpression(nameof(@delegate))] string? doNotPopulateThisValue = null) where TException : Exception => ThrowsAsync(async () => await @delegate, doNotPopulateThisValue); - - public static Task ThrowsAsync(ValueTask @delegate, + + public static ThrowsException ThrowsAsync(ValueTask @delegate, [CallerArgumentExpression(nameof(@delegate))] string? doNotPopulateThisValue = null) where TException : Exception => ThrowsAsync(async () => await @delegate, doNotPopulateThisValue); - - public static async Task ThrowsAsync(Func @delegate, [CallerArgumentExpression(nameof(@delegate))] string? doNotPopulateThisValue = null) where TException : Exception - { - return (TException)await ThrowsAsync(typeof(TException), @delegate, doNotPopulateThisValue); - } - - public static Task ThrowsAsync(string parameterName, - Task @delegate, - [CallerArgumentExpression(nameof(@delegate))] string? doNotPopulateThisValue = null) where TException : ArgumentException - => ThrowsAsync(parameterName, async () => await @delegate, doNotPopulateThisValue); - - public static Task ThrowsAsync(string parameterName, - ValueTask @delegate, - [CallerArgumentExpression(nameof(@delegate))] string? doNotPopulateThisValue = null) where TException : ArgumentException - => ThrowsAsync(parameterName, async () => await @delegate, doNotPopulateThisValue); - - public static async Task ThrowsAsync(string parameterName, - Func @delegate, - [CallerArgumentExpression(nameof(@delegate))] string? doNotPopulateThisValue = null) where TException : ArgumentException + + public static ThrowsException ThrowsAsync(Func @delegate, [CallerArgumentExpression(nameof(@delegate))] string? doNotPopulateThisValue = null) where TException : Exception { - var ex = (TException)await ThrowsAsync(typeof(TException), @delegate, doNotPopulateThisValue); - - if (ex.ParamName?.Equals(parameterName, StringComparison.Ordinal) == false) - { - Fail($"Incorrect parameter name {new StringDifference(ex.ParamName, parameterName).ToString("it differs at index")}"); - } - - return ex; + var throwsException = ThrowsAsync(typeof(TException), @delegate, doNotPopulateThisValue); + + return Unsafe.As>(throwsException); } - - public static Task ThrowsAsync(Type type, Task @delegate, + + public static ThrowsException ThrowsAsync(Type type, Task @delegate, [CallerArgumentExpression(nameof(@delegate))] string? doNotPopulateThisValue = null) => ThrowsAsync(type, async () => await @delegate, doNotPopulateThisValue); - - public static Task ThrowsAsync(Type type, ValueTask @delegate, + + public static ThrowsException ThrowsAsync(Type type, ValueTask @delegate, [CallerArgumentExpression(nameof(@delegate))] string? doNotPopulateThisValue = null) => ThrowsAsync(type, async () => await @delegate, doNotPopulateThisValue); - - public static async Task ThrowsAsync(Type type, Func @delegate, [CallerArgumentExpression(nameof(@delegate))] string? doNotPopulateThisValue = null) + + public static ThrowsException ThrowsAsync(Type type, Func @delegate, [CallerArgumentExpression(nameof(@delegate))] string? doNotPopulateThisValue = null) { - try - { - await @delegate(); - } - catch (Exception e) when (type.IsAssignableFrom(e.GetType())) - { - return e; - } - catch (Exception e) - { - Fail($"Exception is of type {e.GetType().Name} instead of {type.Name} for {doNotPopulateThisValue.GetStringOr("the delegate")}"); - } + return That(@delegate, doNotPopulateThisValue).Throws(type); + } + + public static ThrowsException ThrowsAsync(string parameterName, + Task @delegate, + [CallerArgumentExpression(nameof(@delegate))] string? doNotPopulateThisValue = null, + [CallerArgumentExpression(nameof(parameterName))] string? doNotPopulateThisValue2 = null) where TException : ArgumentException + => ThrowsAsync(parameterName, async () => await @delegate, doNotPopulateThisValue, doNotPopulateThisValue2); - Fail($"No exception was thrown by {doNotPopulateThisValue.GetStringOr("the delegate")}"); + public static ThrowsException ThrowsAsync(string parameterName, + ValueTask @delegate, + [CallerArgumentExpression(nameof(@delegate))] string? doNotPopulateThisValue = null, + [CallerArgumentExpression(nameof(parameterName))] string? doNotPopulateThisValue2 = null) where TException : ArgumentException + => ThrowsAsync(parameterName, async () => await @delegate, doNotPopulateThisValue, doNotPopulateThisValue2); - return null; + public static ThrowsException ThrowsAsync(string parameterName, + Func @delegate, + [CallerArgumentExpression(nameof(@delegate))] string? doNotPopulateThisValue = null, + [CallerArgumentExpression(nameof(parameterName))] string? doNotPopulateThisValue2 = null) where TException : ArgumentException + { + return That(@delegate, doNotPopulateThisValue).Throws().WithParameterName(parameterName, doNotPopulateThisValue2); } public static Exception Throws(Action @delegate, [CallerArgumentExpression(nameof(@delegate))] string? doNotPopulateThisValue = null) => Throws(@delegate, doNotPopulateThisValue); - + public static Exception Throws(Type type, Action @delegate, [CallerArgumentExpression(nameof(@delegate))] string? doNotPopulateThisValue = null) { try @@ -160,17 +145,12 @@ public static Exception Throws(Type type, Action @delegate, [CallerArgumentExpre { Fail($"Exception is of type {e.GetType().Name} instead of {type.Name} for {doNotPopulateThisValue.GetStringOr("the delegate")}"); } - + Fail($"No exception was thrown by {doNotPopulateThisValue.GetStringOr("the delegate")}"); return null; } - - public static TException Throws(Action @delegate, [CallerArgumentExpression(nameof(@delegate))] string? doNotPopulateThisValue = null) where TException : Exception - { - return (TException)Throws(typeof(TException), @delegate, doNotPopulateThisValue); - } - + public static TException Throws(string parameterName, Action @delegate, [CallerArgumentExpression(nameof(@delegate))] string? doNotPopulateThisValue = null) where TException : ArgumentException { var ex = Throws(@delegate, doNotPopulateThisValue); @@ -182,6 +162,11 @@ public static TException Throws(string parameterName, Action @delega return ex; } + + public static TException Throws(Action @delegate, [CallerArgumentExpression(nameof(@delegate))] string? doNotPopulateThisValue = null) where TException : Exception + { + return (TException) Throws(typeof(TException), @delegate, doNotPopulateThisValue); + } [DoesNotReturn] public static void Fail(string reason) => TUnit.Assertions.Fail.Test(reason); diff --git a/TUnit.Assertions/Assertions/Throws/ThrowsException.cs b/TUnit.Assertions/Assertions/Throws/ThrowsException.cs index dc96749253..cd411770f9 100644 --- a/TUnit.Assertions/Assertions/Throws/ThrowsException.cs +++ b/TUnit.Assertions/Assertions/Throws/ThrowsException.cs @@ -58,4 +58,6 @@ public ThrowsException WithInnerException() public DelegateOr Or => _delegateAssertionBuilder.Or; internal void RegisterAssertion(Func, BaseAssertCondition> conditionFunc, string?[] argumentExpressions, [CallerMemberName] string? caller = null) => _source.RegisterAssertion(conditionFunc(_selector), argumentExpressions, caller); + + public static explicit operator Task(ThrowsException throwsException) => Task.Run(async () => await throwsException); } \ No newline at end of file diff --git a/TUnit.Assertions/Assertions/Throws/ThrowsExtensions.cs b/TUnit.Assertions/Assertions/Throws/ThrowsExtensions.cs index 981c7202e3..16ffc02ffc 100644 --- a/TUnit.Assertions/Assertions/Throws/ThrowsExtensions.cs +++ b/TUnit.Assertions/Assertions/Throws/ThrowsExtensions.cs @@ -17,6 +17,14 @@ public static class ThrowsExtensions delegateSource, e => e); } + + public static ThrowsException Throws(this IDelegateSource delegateSource, Type type, [CallerArgumentExpression("type")] string? doNotPopulateThisValue = null) + { + return new ThrowsException( + delegateSource.RegisterAssertion(new ThrowsOfTypeAssertCondition(), [doNotPopulateThisValue]), + delegateSource, + e => e); + } public static ThrowsException ThrowsExactly(this IDelegateSource delegateSource) where TException : Exception @@ -27,16 +35,24 @@ public static class ThrowsExtensions e => e); } - public static InvokableDelegateAssertionBuilder ThrowsWithin(this IDelegateSource delegateSource, TimeSpan timeSpan, [CallerArgumentExpression("timeSpan")] string? doNotPopulateThisValue = null) + public static ThrowsException ThrowsWithin(this IDelegateSource delegateSource, TimeSpan timeSpan, [CallerArgumentExpression("timeSpan")] string? doNotPopulateThisValue = null) { - return delegateSource.RegisterAssertion(new ThrowsWithinAssertCondition(timeSpan), [doNotPopulateThisValue]); + return new ThrowsException( + delegateSource.RegisterAssertion(new ThrowsWithinAssertCondition(timeSpan), [doNotPopulateThisValue]), + delegateSource, + e => e + ); } - public static InvokableDelegateAssertionBuilder ThrowsWithin(this IDelegateSource delegateSource, TimeSpan timeSpan, [CallerArgumentExpression("timeSpan")] string? doNotPopulateThisValue = null) + public static ThrowsException ThrowsWithin(this IDelegateSource delegateSource, TimeSpan timeSpan, [CallerArgumentExpression("timeSpan")] string? doNotPopulateThisValue = null) where TException : Exception { - return delegateSource.RegisterAssertion(new ThrowsWithinAssertCondition(timeSpan), [doNotPopulateThisValue], - $"{nameof(ThrowsWithin)}<{typeof(TException).Name}>"); + return new ThrowsException( + delegateSource.RegisterAssertion(new ThrowsWithinAssertCondition(timeSpan), [doNotPopulateThisValue], + $"{nameof(ThrowsWithin)}<{typeof(TException).Name}>"), + delegateSource, + e => e + ); } public static ThrowsException ThrowsException(this IDelegateSource delegateSource) diff --git a/TUnit.Assertions/Assertions/Throws/ThrowsOfTypeAssertCondition.cs b/TUnit.Assertions/Assertions/Throws/ThrowsOfTypeAssertCondition.cs index 4aea80d2f9..ff63f91094 100644 --- a/TUnit.Assertions/Assertions/Throws/ThrowsOfTypeAssertCondition.cs +++ b/TUnit.Assertions/Assertions/Throws/ThrowsOfTypeAssertCondition.cs @@ -2,7 +2,24 @@ namespace TUnit.Assertions.AssertConditions.Throws; -public class ThrowsOfTypeAssertCondition : DelegateAssertCondition +public class ThrowsOfTypeAssertCondition(Type type) : DelegateAssertCondition +{ + internal protected override string GetExpectation() + => $"to throw {type.Name.PrependAOrAn()}"; + + protected override ValueTask GetResult( + object? actualValue, Exception? exception, + AssertionMetadata assertionMetadata + ) + => AssertionResult + .FailIf(exception is null, "none was thrown") + .OrFailIf(!type.IsAssignableFrom(exception?.GetType()), + $"{exception?.GetType().Name.PrependAOrAn()} was thrown" + ); +} + +public class ThrowsOfTypeAssertCondition : DelegateAssertCondition + where TExpectedException : Exception { internal protected override string GetExpectation() => $"to throw {typeof(TExpectedException).Name.PrependAOrAn()}"; @@ -12,8 +29,8 @@ protected override ValueTask GetResult( AssertionMetadata assertionMetadata ) => AssertionResult - .FailIf(exception is null, "none was thrown") - .OrFailIf(!typeof(TExpectedException).IsAssignableFrom(exception?.GetType()), - $"{exception?.GetType().Name.PrependAOrAn()} was thrown" - ); + .FailIf(exception is null, "none was thrown") + .OrFailIf(!typeof(TExpectedException).IsAssignableFrom(exception?.GetType()), + $"{exception?.GetType().Name.PrependAOrAn()} was thrown" + ); } \ No newline at end of file diff --git a/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.DotNet2_0.verified.txt b/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.DotNet2_0.verified.txt index f70539838b..6f85cb944f 100644 --- a/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.DotNet2_0.verified.txt +++ b/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.DotNet2_0.verified.txt @@ -22,23 +22,23 @@ namespace TUnit.Assertions where TException : System.Exception { } public static TException Throws(string parameterName, System.Action @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) where TException : System.ArgumentException { } - public static System.Threading.Tasks.Task ThrowsAsync(System.Func @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) { } - public static System.Threading.Tasks.Task ThrowsAsync(System.Threading.Tasks.Task @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) { } - public static System.Threading.Tasks.Task ThrowsAsync(System.Threading.Tasks.ValueTask @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) { } - public static System.Threading.Tasks.Task ThrowsAsync(System.Type type, System.Func @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) { } - public static System.Threading.Tasks.Task ThrowsAsync(System.Type type, System.Threading.Tasks.Task @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) { } - public static System.Threading.Tasks.Task ThrowsAsync(System.Type type, System.Threading.Tasks.ValueTask @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) { } - public static System.Threading.Tasks.Task ThrowsAsync(System.Func @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) + public static TUnit.Assertions.AssertConditions.Throws.ThrowsException ThrowsAsync(System.Func @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) { } + public static TUnit.Assertions.AssertConditions.Throws.ThrowsException ThrowsAsync(System.Threading.Tasks.Task @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) { } + public static TUnit.Assertions.AssertConditions.Throws.ThrowsException ThrowsAsync(System.Threading.Tasks.ValueTask @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) { } + public static TUnit.Assertions.AssertConditions.Throws.ThrowsException ThrowsAsync(System.Type type, System.Func @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) { } + public static TUnit.Assertions.AssertConditions.Throws.ThrowsException ThrowsAsync(System.Type type, System.Threading.Tasks.Task @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) { } + public static TUnit.Assertions.AssertConditions.Throws.ThrowsException ThrowsAsync(System.Type type, System.Threading.Tasks.ValueTask @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) { } + public static TUnit.Assertions.AssertConditions.Throws.ThrowsException ThrowsAsync(System.Func @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) where TException : System.Exception { } - public static System.Threading.Tasks.Task ThrowsAsync(System.Threading.Tasks.Task @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) + public static TUnit.Assertions.AssertConditions.Throws.ThrowsException ThrowsAsync(System.Threading.Tasks.Task @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) where TException : System.Exception { } - public static System.Threading.Tasks.Task ThrowsAsync(System.Threading.Tasks.ValueTask @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) + public static TUnit.Assertions.AssertConditions.Throws.ThrowsException ThrowsAsync(System.Threading.Tasks.ValueTask @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) where TException : System.Exception { } - public static System.Threading.Tasks.Task ThrowsAsync(string parameterName, System.Func @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) + public static TUnit.Assertions.AssertConditions.Throws.ThrowsException ThrowsAsync(string parameterName, System.Func @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null, [System.Runtime.CompilerServices.CallerArgumentExpression("parameterName")] string? doNotPopulateThisValue2 = null) where TException : System.ArgumentException { } - public static System.Threading.Tasks.Task ThrowsAsync(string parameterName, System.Threading.Tasks.Task @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) + public static TUnit.Assertions.AssertConditions.Throws.ThrowsException ThrowsAsync(string parameterName, System.Threading.Tasks.Task @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null, [System.Runtime.CompilerServices.CallerArgumentExpression("parameterName")] string? doNotPopulateThisValue2 = null) where TException : System.ArgumentException { } - public static System.Threading.Tasks.Task ThrowsAsync(string parameterName, System.Threading.Tasks.ValueTask @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) + public static TUnit.Assertions.AssertConditions.Throws.ThrowsException ThrowsAsync(string parameterName, System.Threading.Tasks.ValueTask @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null, [System.Runtime.CompilerServices.CallerArgumentExpression("parameterName")] string? doNotPopulateThisValue2 = null) where TException : System.ArgumentException { } } public readonly struct AssertionData : System.IEquatable @@ -567,9 +567,11 @@ namespace TUnit.Assertions.AssertConditions.Throws public TUnit.Assertions.AssertConditions.Throws.ThrowsException WithInnerException() { } public TUnit.Assertions.AssertConditions.Throws.ThrowsException WithMessage(string expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string? doNotPopulateThisValue = null) { } public TUnit.Assertions.AssertConditions.Throws.ThrowsException WithMessageMatching(TUnit.Assertions.AssertConditions.StringMatcher match, [System.Runtime.CompilerServices.CallerArgumentExpression("match")] string? doNotPopulateThisValue = null) { } + public static System.Threading.Tasks.Task op_Explicit(TUnit.Assertions.AssertConditions.Throws.ThrowsException throwsException) { } } public static class ThrowsExtensions { + public static TUnit.Assertions.AssertConditions.Throws.ThrowsException Throws(this TUnit.Assertions.AssertConditions.Interfaces.IDelegateSource delegateSource, System.Type type, [System.Runtime.CompilerServices.CallerArgumentExpression("type")] string? doNotPopulateThisValue = null) { } public static TUnit.Assertions.AssertConditions.Throws.ThrowsException Throws(this TUnit.Assertions.AssertConditions.Interfaces.IDelegateSource delegateSource) where TException : System.Exception { } public static TUnit.Assertions.AssertConditions.Throws.ThrowsException ThrowsExactly(this TUnit.Assertions.AssertConditions.Interfaces.IDelegateSource delegateSource) @@ -577,8 +579,8 @@ namespace TUnit.Assertions.AssertConditions.Throws public static TUnit.Assertions.AssertConditions.Throws.ThrowsException ThrowsException(this TUnit.Assertions.AssertConditions.Interfaces.IDelegateSource delegateSource) { } public static TUnit.Assertions.AssertionBuilders.CastableResultAssertionBuilder ThrowsNothing(this TUnit.Assertions.AssertConditions.Interfaces.IDelegateSource delegateSource) { } public static TUnit.Assertions.AssertionBuilders.CastableResultAssertionBuilder ThrowsNothing(this TUnit.Assertions.AssertConditions.Interfaces.IValueDelegateSource delegateSource) { } - public static TUnit.Assertions.AssertionBuilders.InvokableDelegateAssertionBuilder ThrowsWithin(this TUnit.Assertions.AssertConditions.Interfaces.IDelegateSource delegateSource, System.TimeSpan timeSpan, [System.Runtime.CompilerServices.CallerArgumentExpression("timeSpan")] string? doNotPopulateThisValue = null) { } - public static TUnit.Assertions.AssertionBuilders.InvokableDelegateAssertionBuilder ThrowsWithin(this TUnit.Assertions.AssertConditions.Interfaces.IDelegateSource delegateSource, System.TimeSpan timeSpan, [System.Runtime.CompilerServices.CallerArgumentExpression("timeSpan")] string? doNotPopulateThisValue = null) + public static TUnit.Assertions.AssertConditions.Throws.ThrowsException ThrowsWithin(this TUnit.Assertions.AssertConditions.Interfaces.IDelegateSource delegateSource, System.TimeSpan timeSpan, [System.Runtime.CompilerServices.CallerArgumentExpression("timeSpan")] string? doNotPopulateThisValue = null) { } + public static TUnit.Assertions.AssertConditions.Throws.ThrowsException ThrowsWithin(this TUnit.Assertions.AssertConditions.Interfaces.IDelegateSource delegateSource, System.TimeSpan timeSpan, [System.Runtime.CompilerServices.CallerArgumentExpression("timeSpan")] string? doNotPopulateThisValue = null) where TException : System.Exception { } public static TUnit.Assertions.AssertConditions.Throws.ThrowsException WithParameterName(this TUnit.Assertions.AssertConditions.Throws.ThrowsException throwsException, string expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string? doNotPopulateThisValue = null) where TException : System.ArgumentException { } @@ -589,7 +591,14 @@ namespace TUnit.Assertions.AssertConditions.Throws protected override string GetExpectation() { } protected override System.Threading.Tasks.ValueTask GetResult(TActual? actualValue, System.Exception? exception, TUnit.Assertions.AssertionMetadata assertionMetadata) { } } - public class ThrowsOfTypeAssertCondition : TUnit.Assertions.AssertConditions.DelegateAssertCondition + public class ThrowsOfTypeAssertCondition : TUnit.Assertions.AssertConditions.DelegateAssertCondition + { + public ThrowsOfTypeAssertCondition(System.Type type) { } + protected override string GetExpectation() { } + protected override System.Threading.Tasks.ValueTask GetResult(object? actualValue, System.Exception? exception, TUnit.Assertions.AssertionMetadata assertionMetadata) { } + } + public class ThrowsOfTypeAssertCondition : TUnit.Assertions.AssertConditions.DelegateAssertCondition + where TExpectedException : System.Exception { public ThrowsOfTypeAssertCondition() { } protected override string GetExpectation() { } diff --git a/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.DotNet8_0.verified.txt b/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.DotNet8_0.verified.txt index 5b9367ef1d..f0b3ebd739 100644 --- a/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.DotNet8_0.verified.txt +++ b/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.DotNet8_0.verified.txt @@ -22,23 +22,23 @@ namespace TUnit.Assertions where TException : System.Exception { } public static TException Throws(string parameterName, System.Action @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) where TException : System.ArgumentException { } - public static System.Threading.Tasks.Task ThrowsAsync(System.Func @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) { } - public static System.Threading.Tasks.Task ThrowsAsync(System.Threading.Tasks.Task @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) { } - public static System.Threading.Tasks.Task ThrowsAsync(System.Threading.Tasks.ValueTask @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) { } - public static System.Threading.Tasks.Task ThrowsAsync(System.Type type, System.Func @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) { } - public static System.Threading.Tasks.Task ThrowsAsync(System.Type type, System.Threading.Tasks.Task @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) { } - public static System.Threading.Tasks.Task ThrowsAsync(System.Type type, System.Threading.Tasks.ValueTask @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) { } - public static System.Threading.Tasks.Task ThrowsAsync(System.Func @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) + public static TUnit.Assertions.AssertConditions.Throws.ThrowsException ThrowsAsync(System.Func @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) { } + public static TUnit.Assertions.AssertConditions.Throws.ThrowsException ThrowsAsync(System.Threading.Tasks.Task @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) { } + public static TUnit.Assertions.AssertConditions.Throws.ThrowsException ThrowsAsync(System.Threading.Tasks.ValueTask @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) { } + public static TUnit.Assertions.AssertConditions.Throws.ThrowsException ThrowsAsync(System.Type type, System.Func @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) { } + public static TUnit.Assertions.AssertConditions.Throws.ThrowsException ThrowsAsync(System.Type type, System.Threading.Tasks.Task @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) { } + public static TUnit.Assertions.AssertConditions.Throws.ThrowsException ThrowsAsync(System.Type type, System.Threading.Tasks.ValueTask @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) { } + public static TUnit.Assertions.AssertConditions.Throws.ThrowsException ThrowsAsync(System.Func @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) where TException : System.Exception { } - public static System.Threading.Tasks.Task ThrowsAsync(System.Threading.Tasks.Task @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) + public static TUnit.Assertions.AssertConditions.Throws.ThrowsException ThrowsAsync(System.Threading.Tasks.Task @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) where TException : System.Exception { } - public static System.Threading.Tasks.Task ThrowsAsync(System.Threading.Tasks.ValueTask @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) + public static TUnit.Assertions.AssertConditions.Throws.ThrowsException ThrowsAsync(System.Threading.Tasks.ValueTask @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) where TException : System.Exception { } - public static System.Threading.Tasks.Task ThrowsAsync(string parameterName, System.Func @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) + public static TUnit.Assertions.AssertConditions.Throws.ThrowsException ThrowsAsync(string parameterName, System.Func @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null, [System.Runtime.CompilerServices.CallerArgumentExpression("parameterName")] string? doNotPopulateThisValue2 = null) where TException : System.ArgumentException { } - public static System.Threading.Tasks.Task ThrowsAsync(string parameterName, System.Threading.Tasks.Task @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) + public static TUnit.Assertions.AssertConditions.Throws.ThrowsException ThrowsAsync(string parameterName, System.Threading.Tasks.Task @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null, [System.Runtime.CompilerServices.CallerArgumentExpression("parameterName")] string? doNotPopulateThisValue2 = null) where TException : System.ArgumentException { } - public static System.Threading.Tasks.Task ThrowsAsync(string parameterName, System.Threading.Tasks.ValueTask @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) + public static TUnit.Assertions.AssertConditions.Throws.ThrowsException ThrowsAsync(string parameterName, System.Threading.Tasks.ValueTask @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null, [System.Runtime.CompilerServices.CallerArgumentExpression("parameterName")] string? doNotPopulateThisValue2 = null) where TException : System.ArgumentException { } } public readonly struct AssertionData : System.IEquatable @@ -582,9 +582,11 @@ namespace TUnit.Assertions.AssertConditions.Throws public TUnit.Assertions.AssertConditions.Throws.ThrowsException WithInnerException() { } public TUnit.Assertions.AssertConditions.Throws.ThrowsException WithMessage(string expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string? doNotPopulateThisValue = null) { } public TUnit.Assertions.AssertConditions.Throws.ThrowsException WithMessageMatching(TUnit.Assertions.AssertConditions.StringMatcher match, [System.Runtime.CompilerServices.CallerArgumentExpression("match")] string? doNotPopulateThisValue = null) { } + public static System.Threading.Tasks.Task op_Explicit(TUnit.Assertions.AssertConditions.Throws.ThrowsException throwsException) { } } public static class ThrowsExtensions { + public static TUnit.Assertions.AssertConditions.Throws.ThrowsException Throws(this TUnit.Assertions.AssertConditions.Interfaces.IDelegateSource delegateSource, System.Type type, [System.Runtime.CompilerServices.CallerArgumentExpression("type")] string? doNotPopulateThisValue = null) { } public static TUnit.Assertions.AssertConditions.Throws.ThrowsException Throws(this TUnit.Assertions.AssertConditions.Interfaces.IDelegateSource delegateSource) where TException : System.Exception { } public static TUnit.Assertions.AssertConditions.Throws.ThrowsException ThrowsExactly(this TUnit.Assertions.AssertConditions.Interfaces.IDelegateSource delegateSource) @@ -592,8 +594,8 @@ namespace TUnit.Assertions.AssertConditions.Throws public static TUnit.Assertions.AssertConditions.Throws.ThrowsException ThrowsException(this TUnit.Assertions.AssertConditions.Interfaces.IDelegateSource delegateSource) { } public static TUnit.Assertions.AssertionBuilders.CastableResultAssertionBuilder ThrowsNothing(this TUnit.Assertions.AssertConditions.Interfaces.IDelegateSource delegateSource) { } public static TUnit.Assertions.AssertionBuilders.CastableResultAssertionBuilder ThrowsNothing(this TUnit.Assertions.AssertConditions.Interfaces.IValueDelegateSource delegateSource) { } - public static TUnit.Assertions.AssertionBuilders.InvokableDelegateAssertionBuilder ThrowsWithin(this TUnit.Assertions.AssertConditions.Interfaces.IDelegateSource delegateSource, System.TimeSpan timeSpan, [System.Runtime.CompilerServices.CallerArgumentExpression("timeSpan")] string? doNotPopulateThisValue = null) { } - public static TUnit.Assertions.AssertionBuilders.InvokableDelegateAssertionBuilder ThrowsWithin(this TUnit.Assertions.AssertConditions.Interfaces.IDelegateSource delegateSource, System.TimeSpan timeSpan, [System.Runtime.CompilerServices.CallerArgumentExpression("timeSpan")] string? doNotPopulateThisValue = null) + public static TUnit.Assertions.AssertConditions.Throws.ThrowsException ThrowsWithin(this TUnit.Assertions.AssertConditions.Interfaces.IDelegateSource delegateSource, System.TimeSpan timeSpan, [System.Runtime.CompilerServices.CallerArgumentExpression("timeSpan")] string? doNotPopulateThisValue = null) { } + public static TUnit.Assertions.AssertConditions.Throws.ThrowsException ThrowsWithin(this TUnit.Assertions.AssertConditions.Interfaces.IDelegateSource delegateSource, System.TimeSpan timeSpan, [System.Runtime.CompilerServices.CallerArgumentExpression("timeSpan")] string? doNotPopulateThisValue = null) where TException : System.Exception { } public static TUnit.Assertions.AssertConditions.Throws.ThrowsException WithParameterName(this TUnit.Assertions.AssertConditions.Throws.ThrowsException throwsException, string expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string? doNotPopulateThisValue = null) where TException : System.ArgumentException { } @@ -604,7 +606,14 @@ namespace TUnit.Assertions.AssertConditions.Throws protected override string GetExpectation() { } protected override System.Threading.Tasks.ValueTask GetResult(TActual? actualValue, System.Exception? exception, TUnit.Assertions.AssertionMetadata assertionMetadata) { } } - public class ThrowsOfTypeAssertCondition : TUnit.Assertions.AssertConditions.DelegateAssertCondition + public class ThrowsOfTypeAssertCondition : TUnit.Assertions.AssertConditions.DelegateAssertCondition + { + public ThrowsOfTypeAssertCondition(System.Type type) { } + protected override string GetExpectation() { } + protected override System.Threading.Tasks.ValueTask GetResult(object? actualValue, System.Exception? exception, TUnit.Assertions.AssertionMetadata assertionMetadata) { } + } + public class ThrowsOfTypeAssertCondition : TUnit.Assertions.AssertConditions.DelegateAssertCondition + where TExpectedException : System.Exception { public ThrowsOfTypeAssertCondition() { } protected override string GetExpectation() { } diff --git a/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.DotNet9_0.verified.txt b/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.DotNet9_0.verified.txt index 7279056b26..f610412c45 100644 --- a/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.DotNet9_0.verified.txt +++ b/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.DotNet9_0.verified.txt @@ -22,23 +22,23 @@ namespace TUnit.Assertions where TException : System.Exception { } public static TException Throws(string parameterName, System.Action @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) where TException : System.ArgumentException { } - public static System.Threading.Tasks.Task ThrowsAsync(System.Func @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) { } - public static System.Threading.Tasks.Task ThrowsAsync(System.Threading.Tasks.Task @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) { } - public static System.Threading.Tasks.Task ThrowsAsync(System.Threading.Tasks.ValueTask @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) { } - public static System.Threading.Tasks.Task ThrowsAsync(System.Type type, System.Func @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) { } - public static System.Threading.Tasks.Task ThrowsAsync(System.Type type, System.Threading.Tasks.Task @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) { } - public static System.Threading.Tasks.Task ThrowsAsync(System.Type type, System.Threading.Tasks.ValueTask @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) { } - public static System.Threading.Tasks.Task ThrowsAsync(System.Func @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) + public static TUnit.Assertions.AssertConditions.Throws.ThrowsException ThrowsAsync(System.Func @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) { } + public static TUnit.Assertions.AssertConditions.Throws.ThrowsException ThrowsAsync(System.Threading.Tasks.Task @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) { } + public static TUnit.Assertions.AssertConditions.Throws.ThrowsException ThrowsAsync(System.Threading.Tasks.ValueTask @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) { } + public static TUnit.Assertions.AssertConditions.Throws.ThrowsException ThrowsAsync(System.Type type, System.Func @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) { } + public static TUnit.Assertions.AssertConditions.Throws.ThrowsException ThrowsAsync(System.Type type, System.Threading.Tasks.Task @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) { } + public static TUnit.Assertions.AssertConditions.Throws.ThrowsException ThrowsAsync(System.Type type, System.Threading.Tasks.ValueTask @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) { } + public static TUnit.Assertions.AssertConditions.Throws.ThrowsException ThrowsAsync(System.Func @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) where TException : System.Exception { } - public static System.Threading.Tasks.Task ThrowsAsync(System.Threading.Tasks.Task @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) + public static TUnit.Assertions.AssertConditions.Throws.ThrowsException ThrowsAsync(System.Threading.Tasks.Task @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) where TException : System.Exception { } - public static System.Threading.Tasks.Task ThrowsAsync(System.Threading.Tasks.ValueTask @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) + public static TUnit.Assertions.AssertConditions.Throws.ThrowsException ThrowsAsync(System.Threading.Tasks.ValueTask @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) where TException : System.Exception { } - public static System.Threading.Tasks.Task ThrowsAsync(string parameterName, System.Func @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) + public static TUnit.Assertions.AssertConditions.Throws.ThrowsException ThrowsAsync(string parameterName, System.Func @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null, [System.Runtime.CompilerServices.CallerArgumentExpression("parameterName")] string? doNotPopulateThisValue2 = null) where TException : System.ArgumentException { } - public static System.Threading.Tasks.Task ThrowsAsync(string parameterName, System.Threading.Tasks.Task @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) + public static TUnit.Assertions.AssertConditions.Throws.ThrowsException ThrowsAsync(string parameterName, System.Threading.Tasks.Task @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null, [System.Runtime.CompilerServices.CallerArgumentExpression("parameterName")] string? doNotPopulateThisValue2 = null) where TException : System.ArgumentException { } - public static System.Threading.Tasks.Task ThrowsAsync(string parameterName, System.Threading.Tasks.ValueTask @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null) + public static TUnit.Assertions.AssertConditions.Throws.ThrowsException ThrowsAsync(string parameterName, System.Threading.Tasks.ValueTask @delegate, [System.Runtime.CompilerServices.CallerArgumentExpression("delegate")] string? doNotPopulateThisValue = null, [System.Runtime.CompilerServices.CallerArgumentExpression("parameterName")] string? doNotPopulateThisValue2 = null) where TException : System.ArgumentException { } } public readonly struct AssertionData : System.IEquatable @@ -582,9 +582,11 @@ namespace TUnit.Assertions.AssertConditions.Throws public TUnit.Assertions.AssertConditions.Throws.ThrowsException WithInnerException() { } public TUnit.Assertions.AssertConditions.Throws.ThrowsException WithMessage(string expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string? doNotPopulateThisValue = null) { } public TUnit.Assertions.AssertConditions.Throws.ThrowsException WithMessageMatching(TUnit.Assertions.AssertConditions.StringMatcher match, [System.Runtime.CompilerServices.CallerArgumentExpression("match")] string? doNotPopulateThisValue = null) { } + public static System.Threading.Tasks.Task op_Explicit(TUnit.Assertions.AssertConditions.Throws.ThrowsException throwsException) { } } public static class ThrowsExtensions { + public static TUnit.Assertions.AssertConditions.Throws.ThrowsException Throws(this TUnit.Assertions.AssertConditions.Interfaces.IDelegateSource delegateSource, System.Type type, [System.Runtime.CompilerServices.CallerArgumentExpression("type")] string? doNotPopulateThisValue = null) { } public static TUnit.Assertions.AssertConditions.Throws.ThrowsException Throws(this TUnit.Assertions.AssertConditions.Interfaces.IDelegateSource delegateSource) where TException : System.Exception { } public static TUnit.Assertions.AssertConditions.Throws.ThrowsException ThrowsExactly(this TUnit.Assertions.AssertConditions.Interfaces.IDelegateSource delegateSource) @@ -592,8 +594,8 @@ namespace TUnit.Assertions.AssertConditions.Throws public static TUnit.Assertions.AssertConditions.Throws.ThrowsException ThrowsException(this TUnit.Assertions.AssertConditions.Interfaces.IDelegateSource delegateSource) { } public static TUnit.Assertions.AssertionBuilders.CastableResultAssertionBuilder ThrowsNothing(this TUnit.Assertions.AssertConditions.Interfaces.IDelegateSource delegateSource) { } public static TUnit.Assertions.AssertionBuilders.CastableResultAssertionBuilder ThrowsNothing(this TUnit.Assertions.AssertConditions.Interfaces.IValueDelegateSource delegateSource) { } - public static TUnit.Assertions.AssertionBuilders.InvokableDelegateAssertionBuilder ThrowsWithin(this TUnit.Assertions.AssertConditions.Interfaces.IDelegateSource delegateSource, System.TimeSpan timeSpan, [System.Runtime.CompilerServices.CallerArgumentExpression("timeSpan")] string? doNotPopulateThisValue = null) { } - public static TUnit.Assertions.AssertionBuilders.InvokableDelegateAssertionBuilder ThrowsWithin(this TUnit.Assertions.AssertConditions.Interfaces.IDelegateSource delegateSource, System.TimeSpan timeSpan, [System.Runtime.CompilerServices.CallerArgumentExpression("timeSpan")] string? doNotPopulateThisValue = null) + public static TUnit.Assertions.AssertConditions.Throws.ThrowsException ThrowsWithin(this TUnit.Assertions.AssertConditions.Interfaces.IDelegateSource delegateSource, System.TimeSpan timeSpan, [System.Runtime.CompilerServices.CallerArgumentExpression("timeSpan")] string? doNotPopulateThisValue = null) { } + public static TUnit.Assertions.AssertConditions.Throws.ThrowsException ThrowsWithin(this TUnit.Assertions.AssertConditions.Interfaces.IDelegateSource delegateSource, System.TimeSpan timeSpan, [System.Runtime.CompilerServices.CallerArgumentExpression("timeSpan")] string? doNotPopulateThisValue = null) where TException : System.Exception { } public static TUnit.Assertions.AssertConditions.Throws.ThrowsException WithParameterName(this TUnit.Assertions.AssertConditions.Throws.ThrowsException throwsException, string expected, [System.Runtime.CompilerServices.CallerArgumentExpression("expected")] string? doNotPopulateThisValue = null) where TException : System.ArgumentException { } @@ -604,7 +606,14 @@ namespace TUnit.Assertions.AssertConditions.Throws protected override string GetExpectation() { } protected override System.Threading.Tasks.ValueTask GetResult(TActual? actualValue, System.Exception? exception, TUnit.Assertions.AssertionMetadata assertionMetadata) { } } - public class ThrowsOfTypeAssertCondition : TUnit.Assertions.AssertConditions.DelegateAssertCondition + public class ThrowsOfTypeAssertCondition : TUnit.Assertions.AssertConditions.DelegateAssertCondition + { + public ThrowsOfTypeAssertCondition(System.Type type) { } + protected override string GetExpectation() { } + protected override System.Threading.Tasks.ValueTask GetResult(object? actualValue, System.Exception? exception, TUnit.Assertions.AssertionMetadata assertionMetadata) { } + } + public class ThrowsOfTypeAssertCondition : TUnit.Assertions.AssertConditions.DelegateAssertCondition + where TExpectedException : System.Exception { public ThrowsOfTypeAssertCondition() { } protected override string GetExpectation() { }