Add ImageCore.Tests for TestLocalSystemFilesRetriever
This commit is contained in:
parent
af26d29d19
commit
f3b64e28ed
10 changed files with 86 additions and 10 deletions
26
ImageCore.Tests/ImageCore.Tests.csproj
Normal file
26
ImageCore.Tests/ImageCore.Tests.csproj
Normal 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>
|
45
ImageCore.Tests/TestLocalSystemFilesRetriever.cs
Normal file
45
ImageCore.Tests/TestLocalSystemFilesRetriever.cs
Normal 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]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
BIN
ImageCore.Tests/test_pictures/IMG_0138.HEIC
Normal file
BIN
ImageCore.Tests/test_pictures/IMG_0138.HEIC
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.7 MiB |
BIN
ImageCore.Tests/test_pictures/IMG_0140.HEIC
Normal file
BIN
ImageCore.Tests/test_pictures/IMG_0140.HEIC
Normal file
Binary file not shown.
After Width: | Height: | Size: 1 MiB |
|
@ -7,7 +7,7 @@ namespace Image
|
|||
/// </summary>
|
||||
public class LosslessCompressor : ICompressor
|
||||
{
|
||||
public static readonly LosslessCompressor Instance = new LosslessCompressor();
|
||||
public static readonly LosslessCompressor Instance = new();
|
||||
private readonly ImageOptimizer _imageOptimizer;
|
||||
|
||||
public LosslessCompressor()
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
/// </summary>
|
||||
public class NullCompressor : ICompressor
|
||||
{
|
||||
public static readonly NullCompressor Instance = new NullCompressor();
|
||||
public static readonly NullCompressor Instance = new();
|
||||
|
||||
/// <summary>
|
||||
/// <inheritdoc />
|
||||
|
|
|
@ -2,4 +2,9 @@
|
|||
<s:String x:Key="/Default/Environment/AssemblyExplorer/XmlDocument/@EntryValue"><AssemblyExplorer>
|
||||
<Assembly Path="C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\3.1.0\ref\netcoreapp3.1\System.Net.Mail.dll" />
|
||||
<Assembly Path="C:\Users\nutiu\.nuget\packages\magick.net.core\8.6.1\lib\netstandard21\Magick.NET.Core.dll" />
|
||||
</AssemblyExplorer></s:String></wpf:ResourceDictionary>
|
||||
</AssemblyExplorer></s:String>
|
||||
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=761234b5_002D46ba_002D4312_002Dab60_002Dd15d5d83a61a/@EntryIndexedValue"><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>
|
||||
</SessionState></s:String></wpf:ResourceDictionary>
|
BIN
README.md
BIN
README.md
Binary file not shown.
Loading…
Reference in a new issue