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 { } } } }