File: Utils\TestReader.cs
Web Access
Project: src\test\Libraries\Microsoft.Extensions.DataIngestion.Tests\Microsoft.Extensions.DataIngestion.Tests.csproj (Microsoft.Extensions.DataIngestion.Tests)
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
 
using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
 
namespace Microsoft.Extensions.DataIngestion;
 
internal sealed class TestReader : IngestionDocumentReader
{
    public TestReader(Func<Stream, string, string, CancellationToken, Task<IngestionDocument>> readAsyncCallback)
    {
        ReadAsyncCallback = readAsyncCallback;
    }
 
    public Func<Stream, string, string, CancellationToken, Task<IngestionDocument>> ReadAsyncCallback { get; }
 
    public override Task<IngestionDocument> ReadAsync(Stream source, string identifier, string mediaType, CancellationToken cancellationToken = default)
        => ReadAsyncCallback(source, identifier, mediaType, cancellationToken);
}