Fixes for unit tests
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace PkmnLib.Static.Utils;
|
||||
|
||||
/// <summary>
|
||||
@@ -26,8 +28,18 @@ public readonly record struct StringKey
|
||||
/// <summary>
|
||||
/// Converts a <see cref="string"/> to a <see cref="StringKey"/>.
|
||||
/// </summary>
|
||||
[return: NotNullIfNotNull("key")]
|
||||
public static implicit operator StringKey?(string? key) =>
|
||||
string.IsNullOrWhiteSpace(key) ? null! : new StringKey(key);
|
||||
|
||||
/// <summary>
|
||||
/// Converts a <see cref="string"/> to a <see cref="StringKey"/>.
|
||||
/// Throws an <see cref="ArgumentException"/> if the key is null or whitespace.
|
||||
/// </summary>
|
||||
public static implicit operator StringKey(string key) =>
|
||||
string.IsNullOrWhiteSpace(key) ? default : new StringKey(key);
|
||||
string.IsNullOrWhiteSpace(key)
|
||||
? throw new ArgumentException("Key cannot be null or whitespace.", nameof(key))
|
||||
: new StringKey(key);
|
||||
|
||||
/// <inheritdoc cref="string.ToString()"/>
|
||||
public override string ToString() => _key.ToLowerInvariant();
|
||||
|
||||
Reference in New Issue
Block a user