Browse Source

Add tests

af/merge-core
James Jackson-South 8 years ago
committed by Dirk Lemstra
parent
commit
27b3b00ea1
  1. 29
      tests/ImageSharp.Tests/Formats/ImageFormatManagerTests.cs

29
tests/ImageSharp.Tests/Formats/ImageFormatManagerTests.cs

@ -2,17 +2,15 @@
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using Moq;
using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.IO;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Formats.Png;
using SixLabors.ImageSharp.Formats.Bmp; using SixLabors.ImageSharp.Formats.Bmp;
using SixLabors.ImageSharp.Formats.Jpeg;
using SixLabors.ImageSharp.Formats.Gif; using SixLabors.ImageSharp.Formats.Gif;
using Moq; using SixLabors.ImageSharp.Formats.Jpeg;
using SixLabors.ImageSharp.Formats.Png;
using SixLabors.ImageSharp.PixelFormats;
using Xunit; using Xunit;
@ -125,5 +123,24 @@ namespace SixLabors.ImageSharp.Tests
provider.Verify(x => x.Configure(config)); provider.Verify(x => x.Configure(config));
} }
[Fact]
public void DetectFormatAllocatesCleanBuffer()
{
byte[] jpegImage;
using (var buffer = new MemoryStream())
{
using (var image = new Image<Rgba32>(100, 100))
{
image.SaveAsJpeg(buffer);
jpegImage = buffer.ToArray();
}
}
byte[] invalidImage = { 1, 2, 3 };
Assert.Equal(Image.DetectFormat(jpegImage), JpegFormat.Instance);
Assert.True(Image.DetectFormat(invalidImage) is null);
}
} }
} }

Loading…
Cancel
Save