fix: use proper exception type

This commit is contained in:
Stevan Freeborn
2026-04-02 13:51:25 -05:00
parent d6e22f9f24
commit a819a5ee25
2 changed files with 3 additions and 3 deletions
@@ -8,7 +8,7 @@ internal sealed class StaticKeyProvider : IEncryptionKeyProvider
{ {
if (string.IsNullOrWhiteSpace(base64Key)) if (string.IsNullOrWhiteSpace(base64Key))
{ {
throw new ArgumentNullException(nameof(base64Key)); throw new ArgumentException("Cannot be null or whitespace.", nameof(base64Key));
} }
byte[] decodedKey; byte[] decodedKey;
@@ -22,7 +22,7 @@ internal sealed class StaticKeyProvider : IEncryptionKeyProvider
throw new ArgumentException("The provided key is not a valid Base64 string.", nameof(base64Key), ex); throw new ArgumentException("The provided key is not a valid Base64 string.", nameof(base64Key), ex);
} }
if (decodedKey.Length != 32) if (decodedKey.Length is not 32)
{ {
throw new ArgumentException("The encryption key must be exactly 32 bytes (256 bits) for AES-256 encryption.", nameof(base64Key)); throw new ArgumentException("The encryption key must be exactly 32 bytes (256 bits) for AES-256 encryption.", nameof(base64Key));
} }
@@ -9,7 +9,7 @@ public class StaticKeyProviderTests
{ {
var act = () => new StaticKeyProvider(null!); var act = () => new StaticKeyProvider(null!);
act.Should().Throw<ArgumentNullException>(); act.Should().Throw<ArgumentException>();
} }
[Fact] [Fact]