public string Execute() { State = new Runtime(text, fileCache) { UIConsole = console, ModuleFolders = ModuleFolders.Select(f => (FolderName)f).ToArray() }; block.AutoRegister = false; var result = block.Evaluate(); if (result != null) { LastValue = result.ToString(); LastType = result.Type.ToString(); } else { LastValue = ""; LastType = ""; } var buffer = State.PrintBuffer; Regions.Dispose(); return(buffer.IsNotEmpty() ? buffer : ""); }
public void ModuleTxtShouldBeParsedAndReturnedAsYamlDocument() { var harvester = new ExtensionHarvester(new StubCacheManager(), new StubWebSiteFolder(), new Mock <ICriticalErrorProvider>().Object); IExtensionFolders folders = new ModuleFolders(new[] { _tempFolderName }, harvester); var sample1 = folders.AvailableExtensions().Single(d => d.Id == "Sample1"); Assert.That(sample1.Id, Is.Not.Empty); Assert.That(sample1.Author, Is.EqualTo("Bertrand Le Roy")); // Sample1 }
public void PathsFromFoldersWithModuleTxtShouldFallBackAppropriatelyIfNotGiven() { var harvester = new ExtensionHarvester(new StubCacheManager(), new StubWebSiteFolder(), new Mock <ICriticalErrorProvider>().Object); IExtensionFolders folders = new ModuleFolders(new[] { _tempFolderName }, harvester); var paths = folders.AvailableExtensions().Select(d => d.Path); Assert.That(paths.Count(), Is.EqualTo(5)); Assert.That(paths, Has.Some.EqualTo("Sample1")); // Sample1 - Id, Name invalid URL segment Assert.That(paths, Has.Some.EqualTo("Sample3")); // Sample3 - Id, Name invalid URL segment Assert.That(paths, Has.Some.EqualTo("ThisIs.Sample4")); // Sample4 - Path Assert.That(paths, Has.Some.EqualTo("SampleSix")); // Sample6 - Name, no Path Assert.That(paths, Has.Some.EqualTo("Sample7")); // Sample7 - Id, no Name or Path }
public void NamesFromFoldersWithModuleTxtShouldFallBackToIdIfNotGiven() { var harvester = new ExtensionHarvester(new StubCacheManager(), new StubWebSiteFolder(), new Mock <ICriticalErrorProvider>().Object); IExtensionFolders folders = new ModuleFolders(new[] { _tempFolderName }, harvester); var names = folders.AvailableExtensions().Select(d => d.Name); Assert.That(names.Count(), Is.EqualTo(5)); Assert.That(names, Has.Some.EqualTo("Le plug-in français")); // Sample1 Assert.That(names, Has.Some.EqualTo("This is another test.txt")); // Sample3 Assert.That(names, Has.Some.EqualTo("Sample4")); // Sample4 Assert.That(names, Has.Some.EqualTo("SampleSix")); // Sample6 Assert.That(names, Has.Some.EqualTo("Sample7")); // Sample7 }
public void IdsFromFoldersWithModuleTxtShouldBeListed() { var harvester = new ExtensionHarvester(new StubCacheManager(), new StubWebSiteFolder(), new Mock <ICriticalErrorProvider>().Object); IExtensionFolders folders = new ModuleFolders(new[] { _tempFolderName }, harvester); var ids = folders.AvailableExtensions().Select(d => d.Id); Assert.That(ids.Count(), Is.EqualTo(5)); Assert.That(ids, Has.Some.EqualTo("Sample1")); // Sample1 - obviously Assert.That(ids, Has.Some.EqualTo("Sample3")); // Sample3 Assert.That(ids, Has.Some.EqualTo("Sample4")); // Sample4 Assert.That(ids, Has.Some.EqualTo("Sample6")); // Sample6 Assert.That(ids, Has.Some.EqualTo("Sample7")); // Sample7 }