wabbajack/Wabbajack.Common.Test/MiscTests.cs
Justin Swanson b77fa3d0c7 Made RocksDB initialization lazier
Was causing problems, as it's a singleton across the entire computer, so eagerly initializing them was causing problems for users of Wabbajack.Common that weren't interested in RocksDB.  Only one could run at a time.
2020-08-14 07:16:09 -05:00

42 lines
1.2 KiB
C#

using System.Threading.Tasks;
using Alphaleonis.Win32.Filesystem;
using Xunit;
namespace Wabbajack.Common.Test
{
public class MiscTests
{
[Fact]
public void TestDiskSpeed()
{
using (var queue = new WorkQueue())
{
var speed = Utils.TestDiskSpeed(queue, AbsolutePath.EntryPoint);
}
}
[Fact]
public async Task TestHash()
{
var testFile = ((RelativePath)"text.data").RelativeToEntryPoint();
const string data = "Cheese for Everyone!";
await testFile.WriteAllTextAsync(data);
File.WriteAllText("test.data", data);
Assert.Equal(Hash.FromBase64("eSIyd+KOG3s="), await testFile.FileHashCachedAsync());
Assert.True(testFile.TryGetHashCache(out var fileHash));
Assert.Equal(Hash.FromBase64("eSIyd+KOG3s="), fileHash);
}
[Fact]
public void TestHashHex()
{
var hash = Hash.FromULong((ulong)Utils.NextRandom(0, int.MaxValue));
Assert.Equal(hash, Hash.FromHex(hash.ToHex()));
hash = Hash.FromLong(4085310893299329733);
Assert.Equal(hash, Hash.FromHex(hash.ToHex()));
}
}
}