Files
fil/e2e/csharp/tests/ErrorTests.cs

77 lines
2.6 KiB
C#
Raw Permalink Normal View History

2026-06-01 23:40:55 +02:00
// 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: error.</summary>
public class ErrorTests
{
private static readonly JsonSerializerOptions ConfigOptions = new() { Converters = { new JsonStringEnumConverter(JsonNamingPolicy.SnakeCaseLower) }, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingDefault };
[Fact]
public void Test_ErrorEmptyBytes()
{
// Graceful handling of empty bytes (should not error)
var result = KreuzbergLib.ExtractBytesSync(System.IO.File.ReadAllBytes("text/empty.txt"), "text/plain", new ExtractionConfig());
}
[Fact]
public void Test_ErrorEmptyMime()
{
// Error when extracting with empty MIME type
Assert.ThrowsAny<KreuzbergException>(() =>
{
KreuzbergLib.ExtractBytesSync(System.IO.File.ReadAllBytes("text/plain.txt"), "", new ExtractionConfig());
});
}
[Fact]
public void Test_ErrorExtractBytesConflictingOcr()
{
// extract_bytes force+disable OCR
Assert.ThrowsAny<KreuzbergException>(() =>
{
KreuzbergLib.ExtractBytesSync(System.IO.File.ReadAllBytes("text/fake_text.txt"), "text/plain", new ExtractionConfig { DisableOcr = true, ForceOcr = true });
});
}
[Fact]
public void Test_ErrorInvalidMimeFormat()
{
// Error when extracting with invalid MIME type format
Assert.ThrowsAny<KreuzbergException>(() =>
{
KreuzbergLib.ExtractBytesSync(System.IO.File.ReadAllBytes("text/plain.txt"), "not-a-mime", new ExtractionConfig());
});
}
[Fact]
public void Test_ErrorUnsupportedMime()
{
// Error when extracting with unsupported MIME type
Assert.ThrowsAny<KreuzbergException>(() =>
{
KreuzbergLib.ExtractBytesSync(System.IO.File.ReadAllBytes("text/plain.txt"), "application/x-nonexistent", new ExtractionConfig());
});
}
}
}