2020-03-26 04:25:48 +00:00
|
|
|
|
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())
|
|
|
|
|
{
|
2020-04-22 23:11:06 +00:00
|
|
|
|
var speed = Utils.TestDiskSpeed(queue, AbsolutePath.EntryPoint);
|
2020-03-26 04:25:48 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[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);
|
2020-05-12 21:28:09 +00:00
|
|
|
|
Assert.Equal(Hash.FromBase64("eSIyd+KOG3s="), await testFile.FileHashCachedAsync());
|
2020-08-14 12:16:09 +00:00
|
|
|
|
Assert.True(testFile.TryGetHashCache(out var fileHash));
|
2020-03-26 04:25:48 +00:00
|
|
|
|
Assert.Equal(Hash.FromBase64("eSIyd+KOG3s="), fileHash);
|
|
|
|
|
}
|
2020-05-30 21:05:26 +00:00
|
|
|
|
|
|
|
|
|
[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()));
|
|
|
|
|
}
|
2020-03-26 04:25:48 +00:00
|
|
|
|
}
|
|
|
|
|
}
|