ImgMetadataRemover/ImageCore.Tests/TestNullCompressor.cs

37 lines
1.1 KiB
C#
Raw Permalink Normal View History

2022-01-25 20:19:56 +00:00
using System;
using System.IO;
using Image.Core;
2022-01-25 20:19:56 +00:00
using Xunit;
namespace ImageCore.Tests
{
public class TestNullCompressor
2022-01-25 20:19:56 +00:00
{
private readonly string _testsProjectDirectory;
public TestNullCompressor()
2022-01-25 20:19:56 +00:00
{
_testsProjectDirectory = Environment.GetEnvironmentVariable("IMAGE_CORE_TESTS");
}
2022-04-02 14:22:42 +00:00
2022-01-25 20:19:56 +00:00
[Fact]
public void TestNullCompressor_Compress()
{
ICompressor compressor = new NullCompressor();
2022-04-02 14:22:42 +00:00
var sourceFileName = Path.Combine(_testsProjectDirectory, "test_pictures/IMG_0138.HEIC");
2022-01-25 20:19:56 +00:00
var destinationFileName = Path.GetTempFileName();
File.Copy(sourceFileName, destinationFileName, true);
compressor.Compress(destinationFileName);
2022-04-02 14:22:42 +00:00
2022-01-25 20:19:56 +00:00
var originalFile = File.Open(sourceFileName, FileMode.Open);
var compressedFile = File.Open(destinationFileName, FileMode.Open);
2022-04-02 14:22:42 +00:00
2022-01-25 20:19:56 +00:00
Assert.True(compressedFile.Length == originalFile.Length);
2022-04-02 14:22:42 +00:00
2022-01-25 20:19:56 +00:00
originalFile.Close();
compressedFile.Close();
File.Delete(destinationFileName);
}
}
}