📷 A modern, cross-platform, 2D Graphics library for .NET
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

57 lines
1.8 KiB

// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
using SixLabors.ImageSharp.Formats.Png;
using SixLabors.ImageSharp.Metadata;
namespace SixLabors.ImageSharp.Tests;
public class ImageInfoTests
{
[Fact]
public void ImageInfoInitializesCorrectly()
{
const int width = 50;
const int height = 60;
Size size = new(width, height);
Rectangle rectangle = new(0, 0, width, height);
// Initialize the metadata to match standard decoding behavior.
ImageMetadata meta = new() { DecodedImageFormat = PngFormat.Instance };
meta.GetPngMetadata();
ImageInfo info = new(size, meta);
Assert.NotEqual(default, info.PixelType);
Assert.Equal(width, info.Width);
Assert.Equal(height, info.Height);
Assert.Equal(size, info.Size);
Assert.Equal(rectangle, info.Bounds);
Assert.Equal(meta, info.Metadata);
}
[Fact]
public void ImageInfoInitializesCorrectlyWithFrameMetadata()
{
const int width = 50;
const int height = 60;
Size size = new(width, height);
Rectangle rectangle = new(0, 0, width, height);
// Initialize the metadata to match standard decoding behavior.
ImageMetadata meta = new() { DecodedImageFormat = PngFormat.Instance };
meta.GetPngMetadata();
IReadOnlyList<ImageFrameMetadata> frameMetadata = [new()];
ImageInfo info = new(size, meta, frameMetadata);
Assert.NotEqual(default, info.PixelType);
Assert.Equal(width, info.Width);
Assert.Equal(height, info.Height);
Assert.Equal(size, info.Size);
Assert.Equal(rectangle, info.Bounds);
Assert.Equal(meta, info.Metadata);
Assert.Equal(frameMetadata.Count, info.FrameMetadataCollection.Count);
}
}