给GetLinks新增单元测试,这次更换下载站的时候,文件拷贝过去,最后修改时间改变了。 那个 System.Data.SQLite.zip 成为了最新的一个文件
大石头 authored at 2024-10-17 18:24:23
969.00 B
X
using System;
using System.Collections.Generic;
using System.Linq;
using NewLife;
using NewLife.Web;
using Xunit;

namespace XUnitTest.Web;

public class WebClientTests
{
    [Fact]
    public void GetLinks()
    {
        var client = new WebClientX();
        var links = client.GetLinks("http://x.newlifex.com");
        Assert.NotEmpty(links);

        var names = "System.Data.SQLite.win-x64,System.Data.SQLite.win,System.Data.SQLite_net80,System.Data.SQLite_netstandard21,System.Data.SQLite_netstandard20,System.Data.SQLite".Split(",", ";");

        links = links.Where(e => e.Name.EqualIgnoreCase(names) || e.FullName.EqualIgnoreCase(names)).ToArray();
        var link = links.OrderByDescending(e => e.Version).ThenByDescending(e => e.Time).FirstOrDefault();

        Assert.NotNull(link);
        Assert.Equal("System.Data.SQLite.win-x64", link.Name);
        Assert.True(link.Time >= "2024-05-14".ToDateTime());
        Assert.Null(link.Version);
    }
}