Skip to content

Commit

Permalink
fix By.Hash test
Browse files Browse the repository at this point in the history
  • Loading branch information
alec1o committed May 4, 2024
1 parent 77c6396 commit c72dfd9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/by/By.Hash.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace Byter
Expand Down Expand Up @@ -29,11 +31,11 @@ public static Types Hash<T>(T value)
if (type == typeof(byte[])) return Types.Bytes;
if (type == typeof(string)) return Types.String;
if (type == typeof(BigInteger)) return Types.BigInteger;
if (type.IsClass) return Types.Class;
if (type.IsValueType && !type.IsEnum && !type.IsPrimitive) return Types.Struct;
if (type == typeof(ICollection)) return Types.List;
if (type.IsArray) return Types.Array;
if (type == typeof(DateTime)) return Types.DateTime;
if (type.IsArray) return Types.Array;
if (value is IList) return Types.List;
if (type.IsValueType && !type.IsEnum && !type.IsPrimitive) return Types.Struct;
if (type.IsClass) return Types.Class;

throw new NotImplementedException($"[{nameof(By)}.{nameof(Hash)}] Error: {type} Isn't implemented");
}
Expand Down
2 changes: 1 addition & 1 deletion test/by/By.Hash.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ public void Start()
Assert.Equal(By.Types.BigInteger, By.Hash(@big));
Assert.Equal(By.Types.Class, By.Hash(@class));
Assert.Equal(By.Types.Struct, By.Hash(@struct));
Assert.Equal(By.Types.Array, By.Hash(@array));
Assert.Equal(By.Types.DateTime, By.Hash(date));
Assert.Equal(By.Types.Array, By.Hash(@array));
Assert.Equal(By.Types.List, By.Hash(list));
}
}

0 comments on commit c72dfd9

Please sign in to comment.