54 lines
2.1 KiB
C#
54 lines
2.1 KiB
C#
using MesETL.App.Helpers;
|
|
using MesETL.App.HostedServices;
|
|
using MesETL.App.Options;
|
|
using MesETL.App.Services;
|
|
using MesETL.App.Services.ETL;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.Options;
|
|
using TestProject1.XUnit;
|
|
using Xunit.Abstractions;
|
|
|
|
namespace TestProject1;
|
|
|
|
public class InputServiceTest : TestBase
|
|
{
|
|
private readonly ITestOutputHelper _output;
|
|
|
|
public InputServiceTest(ITestOutputHelper output) : base(output)
|
|
{
|
|
_output = output;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 测试文件输入服务是否能正确的认到应有的文件
|
|
/// </summary>
|
|
/// <param name="inputDir"></param>
|
|
/// <param name="tableOrder"></param>
|
|
/// <param name="ignored"></param>
|
|
/// <param name="assertCount"></param>
|
|
[Theory]
|
|
[InlineData(@"D:\Data\DatabaseDump\MyDumper-ZST 2024-12-3", null, new string[0], 152)] // 没有seq和三个库的efmigration
|
|
[InlineData(@"D:\Data\DatabaseDump\MyDumper-ZST 2024-12-3", new[] { "order", "machine" }, new string[0],
|
|
11)] // 只有order和machine
|
|
[InlineData(@"D:\Data\DatabaseDump\MyDumper-ZST 2024-12-3", null, new[] { "order", "machine" },
|
|
152 - 11)] // 忽略order和machine
|
|
public void Test_InputInfo_Get_And_Order(string inputDir, string[]? tableOrder, string[] ignored, int assertCount)
|
|
{
|
|
var options = new OptionsWrapper<DataInputOptions>(new DataInputOptions()
|
|
{
|
|
InputDir = inputDir,
|
|
FileInputMetaBuilder = DumpDataHelper.MyDumperFileInputMetaBuilder,
|
|
TableOrder = tableOrder,
|
|
TableIgnoreList = ignored
|
|
});
|
|
var ctx = new ProcessContext();
|
|
var queue = new DataRecordQueue();
|
|
var dataReaderFactory = new DataReaderFactory(CreateXUnitLogger<DataReaderFactory>(), options);
|
|
var sut = new FileInputService(CreateXUnitLogger<FileInputService>(), options, ctx, queue, dataReaderFactory,
|
|
new ConfigurationManager());
|
|
|
|
var result = sut.GetOrderedInputInfo(inputDir).ToArray();
|
|
WriteJson(result);
|
|
Assert.True(assertCount == result.Length);
|
|
}
|
|
} |