public void GetPublishProfileNameByIndex_LargerThanIndex() { var data = new PublishPreflight(_testAppSettings, new ConsoleWrapper()).GetPublishProfileNameByIndex(1); Assert.AreEqual(null, data); }
public void GetPublishProfileNameByIndex_0() { var data = new PublishPreflight(_testAppSettings, new ConsoleWrapper()).GetPublishProfileNameByIndex(0); Assert.AreEqual("test", data); }
public void GetAllPublishProfileNames_item() { var list = new PublishPreflight(_testAppSettings, new ConsoleWrapper()).GetAllPublishProfileNames(); Assert.AreEqual("test", list.FirstOrDefault()); }
public void GetPublishProfileNames_listNoContent() { var appSettings = new AppSettings(); var list = new PublishPreflight(appSettings, new ConsoleWrapper()).GetPublishProfileNames(); Assert.AreEqual(0, list.Count); }
public void GetNameConsole_WithArg() { var result = new PublishPreflight(_testAppSettings, new FakeConsoleWrapper()).GetNameConsole("/", new List <string> { "-n", "t" }); Assert.AreEqual("t", result); }
public void GetPublishProfileNames_list() { var list = new PublishPreflight(_testAppSettings, new ConsoleWrapper()).GetPublishProfileNames(); Assert.AreEqual(1, list.Count); Assert.AreEqual("test", list[0].Item2); Assert.AreEqual(0, list[0].Item1); }
public async Task GenerateJpeg_Thumbnail_CorruptOutput_Test() { var appSettings = new AppSettings { PublishProfiles = new Dictionary <string, List <AppSettingsPublishProfiles> > { { "default", new List <AppSettingsPublishProfiles> { new AppSettingsPublishProfiles { ContentType = TemplateContentType.Jpeg, Path = "index.html", MetaData = true, } } } }, Verbose = true }; var storage = new FakeIStorage(new List <string>(), new List <string> { "corrupt" }, new List <byte[]> { CreateAnImage.Bytes }); var selectorStorage = new FakeSelectorStorage(storage); var service = new WebHtmlPublishService(new PublishPreflight(appSettings, new ConsoleWrapper()), selectorStorage, appSettings, new FakeExifTool(storage, appSettings), new FakeIOverlayImage(selectorStorage), new ConsoleWrapper(), new FakeIWebLogger()); var profiles = new PublishPreflight(appSettings, new ConsoleWrapper()).GetPublishProfileName("default"); var generateJpeg = await service.GenerateJpeg(profiles.FirstOrDefault(), new List <FileIndexItem> { new FileIndexItem("/test.jpg") { FileHash = "fileHash" } }, Path.DirectorySeparatorChar.ToString(), 1); // should not output file due corrupt output of image generation Assert.IsTrue(generateJpeg.ContainsKey("test.jpg")); // removed in script due corrupt output Assert.IsFalse(storage.ExistFile(Path.DirectorySeparatorChar + "test.jpg")); }
public void GetNameConsole_UpdateConsoleInput() { var consoleWrapper = new FakeConsoleWrapper { LinesToRead = new List <string> { "updated" } }; var result = new PublishPreflight(_testAppSettings, consoleWrapper).GetNameConsole("/test", new List <string> ()); Assert.AreEqual("updated", result); }
public void GetNameConsole_EnterDefaultOption() { var consoleWrapper = new FakeConsoleWrapper { LinesToRead = new List <string> { string.Empty } }; var result = new PublishPreflight(_testAppSettings, consoleWrapper).GetNameConsole("/test", new List <string> ()); Assert.AreEqual("test", result); }
public async Task GenerateJpeg_Large_Test() { var appSettings = new AppSettings { PublishProfiles = new Dictionary <string, List <AppSettingsPublishProfiles> > { { "default", new List <AppSettingsPublishProfiles> { new AppSettingsPublishProfiles { ContentType = TemplateContentType.Jpeg, Path = "index.html", MetaData = false, SourceMaxWidth = 1001 } } } }, Verbose = true }; var storage = new FakeIStorage(new List <string>(), new List <string> { "/test.jpg" }, new List <byte[]> { CreateAnImage.Bytes }); var selectorStorage = new FakeSelectorStorage(storage); var service = new WebHtmlPublishService(new PublishPreflight(appSettings, new ConsoleWrapper()), selectorStorage, appSettings, new FakeExifTool(storage, appSettings), new FakeIOverlayImage(selectorStorage), new ConsoleWrapper(), new FakeIWebLogger()); var profiles = new PublishPreflight(appSettings, new ConsoleWrapper()).GetPublishProfileName("default"); var generateJpeg = await service.GenerateJpeg(profiles.FirstOrDefault(), new List <FileIndexItem> { new FileIndexItem("/test.jpg") }, Path.DirectorySeparatorChar.ToString(), 1); Assert.IsTrue(generateJpeg.ContainsKey("test.jpg")); Assert.IsTrue(storage.ExistFile(Path.DirectorySeparatorChar + "test.jpg")); }
/// <summary> /// Command Line Helper to server WebHtml Content /// </summary> /// <param name="args">arguments to adjust settings, see starskywebhtml/readme.md for more details</param> /// <returns>void</returns> public async Task Publisher(string[] args) { _appSettings.Verbose = ArgsHelper.NeedVerbose(args); if (_argsHelper.NeedHelp(args)) { _appSettings.ApplicationType = AppSettings.StarskyAppType.WebHtml; _argsHelper.NeedHelpShowDialog(); return; } var inputFullPath = _argsHelper.GetPathFormArgs(args, false); if (string.IsNullOrWhiteSpace(inputFullPath)) { _console.WriteLine("Please use the -p to add a path first"); return; } if (_hostFileSystemStorage.IsFolderOrFile(inputFullPath) != FolderOrFileModel.FolderOrFileTypeList.Folder) { _console.WriteLine("Please add a valid folder: " + inputFullPath + ". " + "This folder is not found"); return; } var settingsFullFilePath = Path.Combine(inputFullPath, "_settings.json"); if (_hostFileSystemStorage.ExistFile(settingsFullFilePath)) { _console.WriteLine($"You have already run this program for this folder remove the " + $"_settings.json first and try it again"); return; } var itemName = _publishPreflight.GetNameConsole(inputFullPath, args); if (_appSettings.IsVerbose()) { _console.WriteLine("Name: " + itemName); _console.WriteLine("inputPath " + inputFullPath); } // used in this session to find the photos back // outside the webRoot of iStorage _appSettings.StorageFolder = inputFullPath; // use relative to StorageFolder var listOfFiles = _subPathStorage.GetAllFilesInDirectory("/") .Where(ExtensionRolesHelper.IsExtensionExifToolSupported).ToList(); var fileIndexList = new ReadMeta(_subPathStorage) .ReadExifAndXmpFromFileAddFilePathHash(listOfFiles); // todo introduce selector var profileName = new PublishPreflight(_appSettings, _console) .GetPublishProfileNameByIndex(0); await _publishService.RenderCopy(fileIndexList, profileName, itemName, inputFullPath, true); _console.WriteLine("publish done"); }