mirror of
https://github.com/SabreTools/SabreTools.Hashing.git
synced 2026-09-22 23:05:09 +00:00
Convert HashType from enum to static class with constants
Because the ordering of the enum was not guaranteed, both because of variances in .NET version and even library version, any change could mean that invisible version bumps would misalign. This attempts to fix that by converting HashType from an enum to a static class with a set of constants instead. This allows logical groupings and orderings without it affecting the values of each item.
This commit is contained in:
@@ -13,7 +13,7 @@ namespace SabreTools.Hashing.Test
|
||||
|
||||
private const long _hashFileSize = 125;
|
||||
|
||||
private static readonly Dictionary<HashType, string> _knownHashes = new()
|
||||
private static readonly Dictionary<string, string> _knownHashes = new()
|
||||
{
|
||||
{HashType.Adler32, "08562d95"},
|
||||
|
||||
@@ -224,7 +224,7 @@ namespace SabreTools.Hashing.Test
|
||||
/// <summary>
|
||||
/// Validate the hashes in a hash dictionary
|
||||
/// </summary>
|
||||
public static void ValidateHashes(Dictionary<HashType, string?>? hashDict)
|
||||
public static void ValidateHashes(Dictionary<string, string?>? hashDict)
|
||||
{
|
||||
Assert.NotNull(hashDict);
|
||||
foreach (var hashType in _knownHashes.Keys)
|
||||
@@ -236,7 +236,7 @@ namespace SabreTools.Hashing.Test
|
||||
/// <summary>
|
||||
/// Validate a single hash
|
||||
/// </summary>
|
||||
public static void ValidateHash(HashType hashType, string? hashValue)
|
||||
public static void ValidateHash(string hashType, string? hashValue)
|
||||
=> Assert.Equal(_knownHashes[hashType], hashValue);
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user