// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Security.Cryptography; using Xunit; namespace Microsoft.AspNetCore.Testing { internal static class ExceptionAssert2 { /// /// Verifies that the code throws an . /// /// A delegate to the code to be tested /// The name of the parameter that should throw the exception /// The that was thrown, when successful /// Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown public static ArgumentNullException ThrowsArgumentNull(Action testCode, string paramName) { var ex = Assert.Throws(testCode); Assert.Equal(paramName, ex.ParamName); return ex; } /// /// Verifies that the code throws a . /// /// A delegate to the code to be tested /// The that was thrown, when successful /// Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown public static CryptographicException ThrowsCryptographicException(Action testCode) { return Assert.Throws(testCode); } } }