Solution layout, build rules with zero-package guard, in-house test framework, localization runtime, brand mark rasteriser with ICO/PNG generation, Core contracts (imaging, video, domain model, TIFF reader), Titano.Tools (make-icon, i18n, xaml-lint, package-guard) and docs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
45 lines
1.3 KiB
C#
45 lines
1.3 KiB
C#
using Titano.Core.Imaging;
|
|
using Titano.Testing;
|
|
|
|
namespace Titano.Core.Tests.Foundation;
|
|
|
|
public sealed class ImageBufferTests
|
|
{
|
|
[Test]
|
|
public void PlanesAreIndependentAndClearedByDefault()
|
|
{
|
|
using var image = new ImageBuffer(4, 3);
|
|
Assert.Equal(12, image.PlaneLength);
|
|
Assert.True(image.Data.ToArray().All(v => v == 0));
|
|
image[1, 2, 1] = 0.5f;
|
|
Assert.Equal(0.5f, image.Plane(1)[1 * 4 + 2]);
|
|
Assert.Equal(0f, image.Plane(0)[1 * 4 + 2]);
|
|
}
|
|
|
|
[Test]
|
|
public void CloneCopiesPixels()
|
|
{
|
|
using var image = new ImageBuffer(2, 2, 1);
|
|
image[0, 1, 1] = 3f;
|
|
using var clone = image.Clone();
|
|
image[0, 1, 1] = 0f;
|
|
Assert.Equal(3f, clone[0, 1, 1]);
|
|
}
|
|
|
|
[Test]
|
|
public void DisposedBufferThrows()
|
|
{
|
|
var image = new ImageBuffer(1, 1);
|
|
image.Dispose();
|
|
Assert.Throws<ObjectDisposedException>(() => _ = image.Storage);
|
|
}
|
|
|
|
[Theory]
|
|
[Case("IMG_0001.CR2", ImageFileFormat.Cr2)]
|
|
[Case("a.jpeg", ImageFileFormat.Jpeg)]
|
|
[Case("photo.HEIC", ImageFileFormat.Heif)]
|
|
[Case("notes.txt", ImageFileFormat.Unknown)]
|
|
public void FormatFromExtension(string name, ImageFileFormat expected) =>
|
|
Assert.Equal(expected, ImageFormatInfo.FromPath(name).Format);
|
|
}
|