public void It_shouldnt_attempt_much_if_folderIco_already_exists() { File.WriteAllText(filmMock.PathTo("folder.ico"), ""); new IconService().Process(filmMock); Assert.IsFalse(File.Exists(filmMock.PathTo("desktop.ini"))); File.Delete(filmMock.PathTo("folder.ico")); }
private void BuildFolderIco(IFilmFromFolder film) { new PosterService().Download(film.Poster, film.PathTo("folder.jpg"), (url, path) => MessageBox.Show("Couldn't download folder.jpg for '" + film.Title + "' from url '" + film.Poster + "' to '" + film.PathTo("folder.jpg") + "'", "Error downloading folder.jpg", MessageBoxButton.OK, MessageBoxImage.Error)); if (!System.IO.File.Exists(film.PathTo("folder.jpg"))) { return; } Task <Bitmap> task = StaTask.Start <Bitmap>(() => new IconLayout(new IconLayoutViewModel(film.PathTo("folder.jpg"), film.Rating)).RenderToBitmap()); task.Wait(); Bitmap icon = task.Result; new PngToIcoService().Convert(icon, film.PathTo("folder.ico")); }
public override void Process(IFilmFromFolder film) { if (System.IO.File.Exists(film.PathTo("folder.ico")) || String.IsNullOrWhiteSpace(film.Rating)) { return; } BuildFolderIco(film); SetupFolderIcon(film.Path); }
public void It_shouldnt_attempt_much_if_folder_has_no_rating() { filmMock = new NotAFilmMock(@"C:\Temp"); new IconService().Process(filmMock); Assert.IsFalse(File.Exists(filmMock.PathTo("desktop.ini"))); }
private void BuildFolderIco(IFilmFromFolder film) { new PosterService().Download(film.Poster, film.PathTo("folder.jpg"), (url, path) => MessageBox.Show("Couldn't download folder.jpg for '" + film.Title + "' from url '" + film.Poster + "' to '" + film.PathTo("folder.jpg") + "'", "Error downloading folder.jpg", MessageBoxButton.OK, MessageBoxImage.Error)); if(!System.IO.File.Exists(film.PathTo("folder.jpg"))) { return; } Task<Bitmap> task = StaTask.Start<Bitmap>(() => new IconLayout(new IconLayoutViewModel(film.PathTo("folder.jpg"), film.Rating)).RenderToBitmap()); task.Wait(); Bitmap icon = task.Result; new PngToIcoService().Convert(icon, film.PathTo("folder.ico")); }