using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using System.Threading.Tasks;
using Dpz.Core.Infrastructure;
using Dpz.Core.Service.RepositoryService;
using Dpz.Core.Service.RepositoryServiceImpl;
using MongoDB.Bson;
using NUnit.Framework;
namespace Dpz.Core.ServiceTest;
[TestFixture]
public class DbLogEntryTest : Basic
{
[Test]
[TestCase("")]
public async Task 获取日志(string startAtId)
{
var filters = new List<string>
{
"Program = 'Dpz.Core.Web.Jobs'",
"SourceContext = 'Serilog.AspNetCore.RequestLoggingMiddleware'",
};
var filter = string.Join(" and ", filters);
IAppLogEntryService service = GetService<IAppLogEntryService>();
var part = await service.GetPageAsync(filter,startAtId);
Assert.IsNotNull(part);
Assert.IsNotNull(part?.Events);
Assert.IsNotEmpty(part?.Events);
var json = JsonSerializer.Serialize(part?.Events, new JsonSerializerOptions { WriteIndented = true });
Console.WriteLine(json);
}
}