ExceptionAssert2.cs 949 B

1234567891011121314151617181920212223
  1. // Copyright (c) .NET Foundation. All rights reserved.
  2. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
  3. using System;
  4. using System.Security.Cryptography;
  5. using Xunit;
  6. namespace Microsoft.AspNetCore.Testing
  7. {
  8. internal static class ExceptionAssert2
  9. {
  10. /// <summary>
  11. /// Verifies that the code throws a <see cref="CryptographicException"/>.
  12. /// </summary>
  13. /// <param name="testCode">A delegate to the code to be tested</param>
  14. /// <returns>The <see cref="CryptographicException"/> that was thrown, when successful</returns>
  15. /// <exception>Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown</exception>
  16. public static CryptographicException ThrowsCryptographicException(Action testCode)
  17. {
  18. return Assert.Throws<CryptographicException>(testCode);
  19. }
  20. }
  21. }