2022-02-11 21:39:34 +00:00
|
|
|
|
using Image.Core;
|
2022-01-25 20:57:40 +00:00
|
|
|
|
using ImageMagick;
|
|
|
|
|
using Moq;
|
|
|
|
|
using Xunit;
|
|
|
|
|
|
|
|
|
|
namespace ImageCore.Tests
|
|
|
|
|
{
|
|
|
|
|
public class TestMetadataRemover
|
|
|
|
|
{
|
|
|
|
|
[Fact]
|
2022-02-12 21:25:34 +00:00
|
|
|
|
public void TestExifRemoverAndCompressorCleanImage()
|
2022-01-25 20:57:40 +00:00
|
|
|
|
{
|
|
|
|
|
// Setup
|
|
|
|
|
var magicImageMock = new Mock<IMagickImage>();
|
|
|
|
|
var compressorMock = new Mock<ICompressor>();
|
2022-02-12 20:12:57 +00:00
|
|
|
|
var metadataRemover = new ExifRemoverAndCompressor(magicImageMock.Object, compressorMock.Object);
|
2022-04-02 14:22:42 +00:00
|
|
|
|
|
2022-01-25 20:57:40 +00:00
|
|
|
|
// Test
|
|
|
|
|
metadataRemover.CleanImage("path");
|
2022-04-02 14:22:42 +00:00
|
|
|
|
|
2022-01-25 20:57:40 +00:00
|
|
|
|
// Assert
|
2022-04-02 14:22:42 +00:00
|
|
|
|
magicImageMock.Verify(i => i.RemoveProfile("exif"));
|
|
|
|
|
magicImageMock.Verify(i => i.Write("path"));
|
|
|
|
|
compressorMock.Verify(i => i.Compress("path"));
|
2022-01-25 20:57:40 +00:00
|
|
|
|
}
|
2022-02-12 21:25:34 +00:00
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestExifRemoverAndCompressorGetImagePath()
|
|
|
|
|
{
|
|
|
|
|
// Setup
|
|
|
|
|
var magicImageMock = new Mock<IMagickImage>();
|
|
|
|
|
magicImageMock.Setup(i => i.FileName).Returns("P4th");
|
2022-04-02 14:22:42 +00:00
|
|
|
|
|
2022-02-12 21:25:34 +00:00
|
|
|
|
var compressorMock = new Mock<ICompressor>();
|
|
|
|
|
var metadataRemover = new ExifRemoverAndCompressor(magicImageMock.Object, compressorMock.Object);
|
|
|
|
|
|
|
|
|
|
// Test
|
|
|
|
|
var result = metadataRemover.GetImagePath();
|
2022-04-02 14:22:42 +00:00
|
|
|
|
|
2022-02-12 21:25:34 +00:00
|
|
|
|
// Assert
|
|
|
|
|
Assert.Equal("P4th", result);
|
|
|
|
|
}
|
2022-01-25 20:57:40 +00:00
|
|
|
|
}
|
|
|
|
|
}
|