public FileOrganizerTests() { serviceProvider = new ServiceCollection() .AddLogging(builder => { builder .AddDebug() .AddSimpleConsole(options => { options.ColorBehavior = LoggerColorBehavior.Default; options.SingleLine = true; options.TimestampFormat = "yyyy-MM-dd"; }); }) .AddTransient <IFileSystem, FileSystem>() .AddTransient <FileOrganizer>() .AddTransient <IImageFileInfoProvider, MockImageFileInfoProvider>() .BuildServiceProvider() ?? throw new ArgumentNullException(nameof(serviceProvider)); fileOrganizer = serviceProvider .GetService <FileOrganizer>() ?? throw new ArgumentNullException(nameof(fileOrganizer)); fileSystem = serviceProvider .GetService <IFileSystem>() ?? throw new ArgumentNullException(nameof(fileSystem)); }
private static void DoRename(MatchFoundEventArgs args, MovideoSettings settings) { if (settings.Reorganize) { var sourcePath = args.LocalFile.Path; IFolderCleaner cleaner = settings.DeleteEmptyFolders ? new FolderCleaner() : null; var organizer = new FileOrganizer(settings.TargetPath, settings.RenameTemplate, cleaner); organizer.Organize(sourcePath, args.Movie); } }
public void DateFormatDirectoryTest() { Assert.True(FileOrganizer.DateFormatDirectory("2018-12-31", "yyyy-MM-dd")); Assert.True(FileOrganizer.DateFormatDirectory("18-12-31", "yy-MM-dd")); Assert.False(FileOrganizer.DateFormatDirectory("201-12-31", "yyyy-MM-dd")); Assert.False(FileOrganizer.DateFormatDirectory("201x-12-31", "yyyy-MM-dd")); Assert.NotNull(fileOrganizer); Assert.True(fileOrganizer.DateFormatDirectory("2018-12-31")); Assert.False(fileOrganizer.DateFormatDirectory("201-12-31")); Assert.False(fileOrganizer.DateFormatDirectory("201x-12-31")); }