ImgMetadataRemover/ImageCore.Tests/TestLocalFileBrowser.cs

45 lines
1.4 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
2022-01-25 20:57:22 +00:00
using Image.Files;
using Xunit;
namespace ImageCore.Tests
{
2022-02-12 20:12:57 +00:00
public class TestLocalFileBrowser
{
private readonly string _testsProjectDirectory;
2022-02-12 20:12:57 +00:00
public TestLocalFileBrowser()
{
_testsProjectDirectory = Environment.GetEnvironmentVariable("IMAGE_CORE_TESTS");
}
[Fact]
public void TestGetFilenamesFromPath_DirectoryNotFound()
{
2022-02-12 20:12:57 +00:00
var filesRetriever = LocalFileBrowser.Create();
Assert.Throws<DirectoryNotFoundException>(() => filesRetriever.GetFilenamesFromPath("a"));
}
[Fact]
public void TestGetFilenamesFromPath()
{
2022-02-12 20:12:57 +00:00
var filesRetriever = LocalFileBrowser.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_0138.jpg", "IMG_0140.HEIC",
};
Assert.NotEmpty(filePathsList);
for (var i = 0; i < filePathsList.Count; i++)
{
Assert.Equal(expectedFileNames[i], Path.GetFileName(filePathsList[i]));
}
}
}
}