网站首页 网站源码
website
站点相关全部源代码,隐藏了一些关于服务器的信息
using MongoDB.Driver.Linq;

namespace Dpz.Core.ServiceTest;

[TestFixture]
public class ArticleServiceTest:Basic
{
    [TestCase("关于代糖的误解")]
    [TestCase("过滤html标签、属性,防止XSS攻击")]
    public async Task ArticleTitleIndexTest(string title)
    {
        var list = await ArticleRepository.SearchFor(x => x.Title == title).ToListAsync();
        
        Assert.IsNotNull(list);
        
        Assert.IsNotEmpty(list);
    }

    [Test]
    public async Task ArticleSearchIndexTest()
    {
        var searchText = "dotnet";
        var search1 = Builders<Article>.Search.Text(x => x.Title, searchText);
        var search2 = Builders<Article>.Search.Text(x => x.Markdown, searchText);
        var searchCompound = Builders<Article>.Search.Compound().Must(search1).Must(search2);
        var list = await ArticleRepository.Collection.Aggregate().Search(searchCompound)
            .ToListAsync();
        
        Assert.IsNotNull(list);
        
        Assert.IsNotEmpty(list);
    }
}
loading