BITKit/Packages/Tests/CacheTest.cs

57 lines
1.3 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.TestTools;
using Newtonsoft.Json;
using System.Reflection;
using System.IO;
using BITKit.IO;
namespace BITKit
{
public class CacheTest
{
public struct MethodIndex
{
public Type type;
public string methodName;
public MethodInfo GetMethodInfo()
{
return type.GetMethod(methodName);
}
}
string path => PathHelper.GetFilePath("Cache", "CacheTest.cache");
[Test]
public void WriteCache()
{
var type = this.GetType();
MethodIndex value = new();
value.type = type;
value.methodName = nameof(ReadCache);
BITCache.Write(nameof(CacheTest), value);
Debug.Log($"已生成缓存:{path}");
}
[Test]
public void ReadCache()
{
if (BITCache.Read<MethodInfo>(path, out var info))
{
Debug.Log("已读取到缓存");
}
else
{
Debug.Log("未读取到缓存");
}
}
[Test]
public void ClearCache()
{
BITCache.Guid = Guid.NewGuid();
}
}
}