Implemented download log files (not in service). Refactored backupservice to handle log file splitting. Improved a few interfaces and added some unit tests around them.
This commit is contained in:
parent
30352403cf
commit
bbb4240e20
22 changed files with 292 additions and 46 deletions
|
|
@ -1,4 +1,6 @@
|
|||
using API.Services;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using API.Services;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NSubstitute;
|
||||
using Xunit;
|
||||
|
|
@ -17,15 +19,60 @@ namespace API.Tests.Services
|
|||
}
|
||||
|
||||
[Fact]
|
||||
public void GetFiles_Test()
|
||||
public void GetFiles_WithCustomRegex_ShouldPass_Test()
|
||||
{
|
||||
//_directoryService.GetFiles()
|
||||
var testDirectory = Path.Join(Directory.GetCurrentDirectory(), "../../../Services/Test Data/DirectoryService/regex");
|
||||
var files = _directoryService.GetFiles(testDirectory, @"file\d*.txt");
|
||||
Assert.Equal(2, files.Count());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetFiles_TopLevel_ShouldBeEmpty_Test()
|
||||
{
|
||||
var testDirectory = Path.Join(Directory.GetCurrentDirectory(), "../../../Services/Test Data/DirectoryService");
|
||||
var files = _directoryService.GetFiles(testDirectory);
|
||||
Assert.Empty(files);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetFilesWithExtensions_ShouldBeEmpty_Test()
|
||||
{
|
||||
var testDirectory = Path.Join(Directory.GetCurrentDirectory(), "../../../Services/Test Data/DirectoryService/extensions");
|
||||
var files = _directoryService.GetFiles(testDirectory, "*.txt");
|
||||
Assert.Empty(files);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetFilesWithExtensions_Test()
|
||||
{
|
||||
var testDirectory = Path.Join(Directory.GetCurrentDirectory(), "../../../Services/Test Data/DirectoryService/extension");
|
||||
var files = _directoryService.GetFiles(testDirectory, ".cbz|.rar");
|
||||
Assert.Equal(3, files.Count());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetFilesWithExtensions_BadDirectory_ShouldBeEmpty_Test()
|
||||
{
|
||||
var testDirectory = Path.Join(Directory.GetCurrentDirectory(), "../../../Services/Test Data/DirectoryService/doesntexist");
|
||||
var files = _directoryService.GetFiles(testDirectory, ".cbz|.rar");
|
||||
Assert.Empty(files);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ListDirectory_Test()
|
||||
public void ListDirectory_SubDirectory_Test()
|
||||
{
|
||||
|
||||
var testDirectory = Path.Join(Directory.GetCurrentDirectory(), "../../../Services/Test Data/DirectoryService/");
|
||||
var dirs = _directoryService.ListDirectory(testDirectory);
|
||||
Assert.Contains(dirs, s => s.Contains("regex"));
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ListDirectory_NoSubDirectory_Test()
|
||||
{
|
||||
var dirs = _directoryService.ListDirectory("");
|
||||
Assert.DoesNotContain(dirs, s => s.Contains("regex"));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue