Refactor code structure for improved readability and maintainability
This commit is contained in:
parent
b47641feaa
commit
4f488bae45
78 changed files with 3309 additions and 1570 deletions
38
dotnet/src/TwitchArchive.Tests/FileManagerServiceTests.cs
Normal file
38
dotnet/src/TwitchArchive.Tests/FileManagerServiceTests.cs
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using Xunit;
|
||||
using TwitchArchive.Core.Services;
|
||||
|
||||
namespace TwitchArchive.Tests
|
||||
{
|
||||
public class FileManagerServiceTests : IDisposable
|
||||
{
|
||||
private readonly string _root;
|
||||
|
||||
public FileManagerServiceTests()
|
||||
{
|
||||
_root = Path.Combine(Path.GetTempPath(), "ta_fm_" + Guid.NewGuid().ToString("N"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EnsureDirectories_CreatesPaths_And_GetUniquePath_AppendsSuffix()
|
||||
{
|
||||
var svc = new FileManagerService(_root);
|
||||
var paths = svc.GetPaths("alice");
|
||||
svc.EnsureDirectories(paths);
|
||||
Assert.True(Directory.Exists(paths.RawPath));
|
||||
Assert.True(Directory.Exists(paths.VideoPath));
|
||||
|
||||
var file = Path.Combine(paths.RawPath, "file.ts");
|
||||
File.WriteAllText(file, "x");
|
||||
var unique = svc.GetUniqueFilePath(file);
|
||||
Assert.NotEqual(file, unique);
|
||||
Assert.Contains("file-", Path.GetFileName(unique));
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
try { Directory.Delete(_root, true); } catch { }
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue