XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFESystem

【Rust】XFE系统,基于Rust和汇编

公开
关注 0 Fork 0 Star 0
UTF-8
using System.Security.Cryptography;
using System.Text.Json;

namespace XFESystem.Platform.Tests;

public sealed class ProvenanceTests
{
    [Fact]
    public void VendoredLunarFontSourcesMatchPinnedOfficialBytesAndRetainLicense()
    {
        var root = new DirectoryInfo(AppContext.BaseDirectory);
        while (root is not null && !Directory.Exists(Path.Combine(root.FullName, "Source", "XFESystem.Platform"))) root = root.Parent;
        Assert.NotNull(root);
        string directory = Path.Combine(root.FullName, "Source", "XFESystem.Platform", "ThirdParty", "LunarFonts");
        using var manifest = JsonDocument.Parse(File.ReadAllBytes(Path.Combine(directory, "SourceManifest.json")));
        Assert.Equal("6501f54cc1a943a1cea304c6a382724cdc7e2146", manifest.RootElement.GetProperty("Commit").GetString());
        foreach (var file in manifest.RootElement.GetProperty("Files").EnumerateArray())
        {
            string path = Path.Combine(directory, file.GetProperty("SnapshotPath").GetString()!);
            Assert.Equal(file.GetProperty("Sha256").GetString(), Convert.ToHexStringLower(SHA256.HashData(File.ReadAllBytes(path))));
            Assert.True(file.GetProperty("Verbatim").GetBoolean());
        }
        Assert.Contains("Copyright (c) 2018 Sérgio Flores", File.ReadAllText(Path.Combine(directory, "LICENSE")));
    }
}