Add ImageCore.Tests for TestLocalSystemFilesRetriever

This commit is contained in:
Denis-Cosmin Nutiu 2022-01-24 21:14:26 +02:00
parent af26d29d19
commit f3b64e28ed
10 changed files with 86 additions and 10 deletions

View file

@ -11,10 +11,10 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.8.0" /> <PackageReference Include="CommandLineParser" Version="2.8.0"/>
<ProjectReference Include="..\ImageCore\ImageCore.csproj" /> <ProjectReference Include="..\ImageCore\ImageCore.csproj"/>
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" /> <PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0"/>
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.0" /> <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.0"/>
</ItemGroup> </ItemGroup>
</Project> </Project>

View file

@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4"/>
<PackageReference Include="xunit" Version="2.4.1"/>
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.0.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ImageCore\ImageCore.csproj"/>
</ItemGroup>
</Project>

View file

@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Image;
using Xunit;
namespace ImageCore.Tests
{
public class TestLocalSystemFilesRetriever
{
private readonly string _testsProjectDirectory;
public TestLocalSystemFilesRetriever()
{
_testsProjectDirectory = Environment.GetEnvironmentVariable("IMAGE_CORE_TESTS");
}
[Fact]
public void TestGetFilenamesFromPath_DirectoryNotFound()
{
var filesRetriever = LocalSystemFilesRetriever.Create();
Assert.Throws<DirectoryNotFoundException>(() => filesRetriever.GetFilenamesFromPath("a"));
}
[Fact]
public void TestGetFilenamesFromPath()
{
var filesRetriever = LocalSystemFilesRetriever.Create();
var filePaths = filesRetriever.GetFilenamesFromPath(Path.Join(_testsProjectDirectory, "test_pictures"));
Assert.NotNull(filePaths);
var filePathsList = filePaths.ToList();
var expectedFileNames = new List<string>
{
"IMG_0138.HEIC", "IMG_0140.HEIC",
};
Assert.NotEmpty(filePathsList);
for (var i = 0; i < filePathsList.Count; i++)
{
Assert.Equal(expectedFileNames[i], Path.GetFileName(filePathsList[i]));
}
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 MiB

View file

@ -6,9 +6,9 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Magick.NET-Q16-AnyCPU" Version="8.6.1" /> <PackageReference Include="Magick.NET-Q16-AnyCPU" Version="8.6.1"/>
<PackageReference Include="Magick.NET.Core" Version="8.6.1" /> <PackageReference Include="Magick.NET.Core" Version="8.6.1"/>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.0" /> <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.0"/>
</ItemGroup> </ItemGroup>
</Project> </Project>

View file

@ -7,7 +7,7 @@ namespace Image
/// </summary> /// </summary>
public class LosslessCompressor : ICompressor public class LosslessCompressor : ICompressor
{ {
public static readonly LosslessCompressor Instance = new LosslessCompressor(); public static readonly LosslessCompressor Instance = new();
private readonly ImageOptimizer _imageOptimizer; private readonly ImageOptimizer _imageOptimizer;
public LosslessCompressor() public LosslessCompressor()

View file

@ -5,7 +5,7 @@
/// </summary> /// </summary>
public class NullCompressor : ICompressor public class NullCompressor : ICompressor
{ {
public static readonly NullCompressor Instance = new NullCompressor(); public static readonly NullCompressor Instance = new();
/// <summary> /// <summary>
/// <inheritdoc /> /// <inheritdoc />

View file

@ -2,4 +2,9 @@
<s:String x:Key="/Default/Environment/AssemblyExplorer/XmlDocument/@EntryValue">&lt;AssemblyExplorer&gt;&#xD; <s:String x:Key="/Default/Environment/AssemblyExplorer/XmlDocument/@EntryValue">&lt;AssemblyExplorer&gt;&#xD;
&lt;Assembly Path="C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\3.1.0\ref\netcoreapp3.1\System.Net.Mail.dll" /&gt;&#xD; &lt;Assembly Path="C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\3.1.0\ref\netcoreapp3.1\System.Net.Mail.dll" /&gt;&#xD;
&lt;Assembly Path="C:\Users\nutiu\.nuget\packages\magick.net.core\8.6.1\lib\netstandard21\Magick.NET.Core.dll" /&gt;&#xD; &lt;Assembly Path="C:\Users\nutiu\.nuget\packages\magick.net.core\8.6.1\lib\netstandard21\Magick.NET.Core.dll" /&gt;&#xD;
&lt;/AssemblyExplorer&gt;</s:String></wpf:ResourceDictionary> &lt;/AssemblyExplorer&gt;</s:String>
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=761234b5_002D46ba_002D4312_002Dab60_002Dd15d5d83a61a/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" IsActive="True" Name="TestGetFilenamesFromPath" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"&gt;&#xD;
&lt;TestAncestor&gt;&#xD;
&lt;TestId&gt;xUnit::8EB81515-E62C-4408-84E0-6C27E0293902::net5.0::ImageCore.Tests.TestLocalSystemFilesRetriever.TestGetFilenamesFromPath&lt;/TestId&gt;&#xD;
&lt;/TestAncestor&gt;&#xD;
&lt;/SessionState&gt;</s:String></wpf:ResourceDictionary>

BIN
README.md

Binary file not shown.