diff --git a/ImageCore.Tests/ImageCore.Tests.csproj b/ImageCore.Tests/ImageCore.Tests.csproj index 4199998..586e233 100644 --- a/ImageCore.Tests/ImageCore.Tests.csproj +++ b/ImageCore.Tests/ImageCore.Tests.csproj @@ -7,8 +7,8 @@ - - + + runtime; build; native; contentfiles; analyzers; buildtransitive all @@ -20,7 +20,7 @@ - + diff --git a/ImageCore.Tests/TestCompressor.cs b/ImageCore.Tests/TestCompressor.cs new file mode 100644 index 0000000..c9beda7 --- /dev/null +++ b/ImageCore.Tests/TestCompressor.cs @@ -0,0 +1,56 @@ +using System; +using System.IO; +using System.Security.Cryptography; +using Image; +using Xunit; + +namespace ImageCore.Tests +{ + public class TestLosslessCompressor + { + private readonly string _testsProjectDirectory; + + public TestLosslessCompressor() + { + _testsProjectDirectory = Environment.GetEnvironmentVariable("IMAGE_CORE_TESTS"); + } + + [Fact] + public void TestLosslessCompressor_Compress() + { + ICompressor compressor = new LosslessCompressor(); + var sourceFileName = Path.Join(_testsProjectDirectory, "test_pictures/IMG_0138.HEIC"); + var destinationFileName = Path.GetTempFileName(); + File.Copy(sourceFileName, destinationFileName, true); + compressor.Compress(destinationFileName); + + var originalFile = File.Open(sourceFileName, FileMode.Open); + var compressedFile = File.Open(destinationFileName, FileMode.Open); + + Assert.True(compressedFile.Length <= originalFile.Length); + + originalFile.Close(); + compressedFile.Close(); + File.Delete(destinationFileName); + } + + [Fact] + public void TestNullCompressor_Compress() + { + ICompressor compressor = new NullCompressor(); + var sourceFileName = Path.Join(_testsProjectDirectory, "test_pictures/IMG_0138.HEIC"); + var destinationFileName = Path.GetTempFileName(); + File.Copy(sourceFileName, destinationFileName, true); + compressor.Compress(destinationFileName); + + var originalFile = File.Open(sourceFileName, FileMode.Open); + var compressedFile = File.Open(destinationFileName, FileMode.Open); + + Assert.True(compressedFile.Length == originalFile.Length); + + originalFile.Close(); + compressedFile.Close(); + File.Delete(destinationFileName); + } + } +} \ No newline at end of file diff --git a/ImgMetadataRemover.sln.DotSettings.user b/ImgMetadataRemover.sln.DotSettings.user index 2a32d30..f219feb 100644 --- a/ImgMetadataRemover.sln.DotSettings.user +++ b/ImgMetadataRemover.sln.DotSettings.user @@ -4,7 +4,5 @@ <Assembly Path="C:\Users\nutiu\.nuget\packages\magick.net.core\8.6.1\lib\netstandard21\Magick.NET.Core.dll" /> </AssemblyExplorer> <SessionState ContinuousTestingMode="0" IsActive="True" Name="TestGetFilenamesFromPath" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"> - <TestAncestor> - <TestId>xUnit::8EB81515-E62C-4408-84E0-6C27E0293902::net5.0::ImageCore.Tests.TestLocalSystemFilesRetriever.TestGetFilenamesFromPath</TestId> - </TestAncestor> + <Project Location="C:\Users\nutiu\RiderProjects\ImgMetadataRemover\ImageCore.Tests" Presentation="&lt;ImageCore.Tests&gt;" /> </SessionState> \ No newline at end of file