63 lines
1.9 KiB
C#
Generated
63 lines
1.9 KiB
C#
Generated
// 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: detection.</summary>
|
|
public class DetectionTests
|
|
{
|
|
private static readonly JsonSerializerOptions ConfigOptions = new() { Converters = { new JsonStringEnumConverter(JsonNamingPolicy.SnakeCaseLower) }, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingDefault };
|
|
|
|
[Fact]
|
|
public void Test_DetectMimeBytesHtml()
|
|
{
|
|
// Detect HTML MIME from bytes
|
|
var result = KreuzbergLib.DetectMimeTypeFromBytes(System.IO.File.ReadAllBytes("html/html.html"));
|
|
|
|
}
|
|
|
|
[Fact]
|
|
public void Test_DetectMimeBytesPdf()
|
|
{
|
|
// Detect PDF MIME type from bytes
|
|
var result = KreuzbergLib.DetectMimeTypeFromBytes(System.IO.File.ReadAllBytes("pdf/fake_memo.pdf"));
|
|
|
|
}
|
|
|
|
[Fact]
|
|
public void Test_DetectMimeBytesPng()
|
|
{
|
|
// Detect PNG MIME type from bytes
|
|
var result = KreuzbergLib.DetectMimeTypeFromBytes(System.IO.File.ReadAllBytes("images/test_hello_world.png"));
|
|
|
|
}
|
|
|
|
[Fact]
|
|
public void Test_GetExtensionsUnknownMime()
|
|
{
|
|
// get_extensions unknown MIME
|
|
Assert.ThrowsAny<KreuzbergException>(() =>
|
|
{
|
|
KreuzbergLib.GetExtensionsForMime("application/x-totally-unknown");
|
|
});
|
|
}
|
|
|
|
|
|
}
|
|
}
|