// This file is auto-generated by alef — DO NOT EDIT.
// alef:hash:4e15143f4af1ae8bafbdb1506ef057da924484c66a19483966333558ad437e75
// To regenerate: alef generate
// To verify freshness: alef verify --exit-code
// Issues & docs: https://github.com/kreuzberg-dev/alef

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using Xunit;
using Kreuzberg;
using static Kreuzberg.KreuzbergLib;

namespace Kreuzberg
{
    /// <summary>E2e tests for category: async.</summary>
    public class AsyncTests
    {
            private static readonly JsonSerializerOptions ConfigOptions = new() { Converters = { new JsonStringEnumConverter(JsonNamingPolicy.SnakeCaseLower) }, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingDefault };

        [Fact]
        public async Task Test_AsyncExtractBytes()
        {
            // Async extract_bytes call on PDF document
            var result = await KreuzbergLib.ExtractBytesAsync(System.IO.File.ReadAllBytes("pdf/fake_memo.pdf"), "application/pdf", null);
    Assert.Equal("application/pdf", result.MimeType!.Trim());
    Assert.True(result.Content.Length >= 50, "expected length >= 50");

        }

        [Fact]
        public async Task Test_AsyncExtractBytesEmptyMime()
        {
            // extract_bytes empty MIME async
            await Assert.ThrowsAnyAsync<KreuzbergException>(async () =>
            {
                await KreuzbergLib.ExtractBytesAsync(System.IO.File.ReadAllBytes("text/plain.txt"), "", ExtractionConfig.FromJson("{}"));
            });
        }

        [Fact]
        public async Task Test_AsyncExtractBytesInvalidMime()
        {
            // extract_bytes unsupported MIME async
            await Assert.ThrowsAnyAsync<KreuzbergException>(async () =>
            {
                await KreuzbergLib.ExtractBytesAsync(System.IO.File.ReadAllBytes("text/plain.txt"), "application/x-nonexistent", ExtractionConfig.FromJson("{}"));
            });
        }


    }
}
