public void HandleJPGFileFoundEventShouldSucceedWhenRenamingImageAndAFileWithThatFileNameAlreadyExists() { handler = new JPGFileHandler(organizer, JPGFileHandler.Naming.EXIFDateTime); exposedHandler = new PrivateObject(handler); List <string> subdirectories = new List <string> { Path.GetRandomFileName(), Path.GetRandomFileName(), Path.GetRandomFileName() }; string fileName = Path.GetRandomFileName() + ".jpg"; string dateTimeOriginal = "2015:10:17 18:18:11"; foreach (string subdirectory in subdirectories) { Directory.CreateDirectory(Path.Combine(sourceDirectoryPath, subdirectory)); string sourceFilePath = Path.Combine(sourceDirectoryPath, subdirectory, fileName); Image image = CreateImage(dateTimeOriginal); image.Save(sourceFilePath, ImageFormat.Jpeg); image.Dispose(); JPGFileFoundEventArgs args = new JPGFileFoundEventArgs(sourceFilePath, destinationDirectoryPath); exposedHandler.Invoke("HandleJPGFileFoundEvent", organizer, args); } List <string> newFileNames = new List <string> { "2015-10-17 18.18.11.jpg", "2015-10-17 18.18.11 1.jpg", "2015-10-17 18.18.11 2.jpg" }; string date = "2015-10-17"; foreach (string newFileName in newFileNames) { string destinationFilePath = Path.Combine(destinationDirectoryPath, date, newFileName); Assert.IsTrue(File.Exists(destinationFilePath)); } }
public void StartOrganization() { JPGFileHandler.Naming namingMode = RenameFilesbyDateAndTime ? JPGFileHandler.Naming.EXIFDateTime : JPGFileHandler.Naming.Original; string fullSourceDirectoryPath = Path.GetFullPath(sourceDirectoryPath); string fullDestinationDirectoryPath = Path.GetFullPath(destinationDirectoryPath); ValidateDirectoryPath(fullSourceDirectoryPath, sourceDirectoryValidator, "SourceDirectoryPath"); ValidateDirectoryPath(destinationDirectoryPath, destinationDirectoryValidator, "DestinationDirectoryPath"); if (!HasErrors) { Progress <int> progress = new Progress <int>(); progress.ProgressChanged += HandleProgressChangedEvent; Organizer organizer = new Organizer(fullSourceDirectoryPath, fullDestinationDirectoryPath, progress); JPGFileHandler jpgFileHandler = new JPGFileHandler(organizer, namingMode); UnsupportedFileHandler unsupportedFileHandler = new UnsupportedFileHandler(organizer); Task.Run(() => organizer.Organize()); } }
public void HandleJPGFileFoundEventShouldSucceedWhenRenamingImageWithEXIFDataTimeOriginalData() { handler = new JPGFileHandler(organizer, JPGFileHandler.Naming.EXIFDateTime); exposedHandler = new PrivateObject(handler); string fileName = Path.GetRandomFileName() + ".jpg"; string dateTimeOriginal = "2015:10:18 18:18:11"; string date = "2015-10-18"; string newFileName = "2015-10-18 18.18.11.jpg"; string sourceFilePath = Path.Combine(sourceDirectoryPath, fileName); string destinationFilePath = Path.Combine(destinationDirectoryPath, date, newFileName); Image image = CreateImage(dateTimeOriginal); image.Save(sourceFilePath, ImageFormat.Jpeg); JPGFileFoundEventArgs args = new JPGFileFoundEventArgs(sourceFilePath, destinationDirectoryPath); exposedHandler.Invoke("HandleJPGFileFoundEvent", organizer, args); Assert.IsTrue(File.Exists(destinationFilePath)); }
public void TestInitialize() { organizer = new Organizer(sourceDirectoryPath, destinationDirectoryPath); handler = new JPGFileHandler(organizer); exposedHandler = new PrivateObject(handler); }