public void GetExpandUrisArgs_Test(string settingsFile, string presentationRoot)
        {
            presentationRoot = ProgramAssemblyUtility.GetPathFromAssembly(this.GetType().Assembly, presentationRoot);

            var args = new ProgramArgs(new[]
            {
                ProgramArgs.SettingsFile, settingsFile,
                ProgramArgs.BasePath, presentationRoot
            });

            var(presentationInfo, settingsInfo) = args.ToPresentationAndSettingsInfo();

            Assert.True(presentationInfo.Exists);
            Assert.True(settingsInfo.Exists);

            var jO = JObject.Parse(File.ReadAllText(settingsInfo.FullName));

            var(entryPath, collapsedHost) = jO.GetExpandUrisArgs(presentationInfo);
            Assert.True(File.Exists(entryPath));
            Assert.False(string.IsNullOrEmpty(collapsedHost));

            var commandName = jO.GetPublicationCommand();

            Assert.Equal(nameof(MarkdownEntryActivity.ExpandUris), commandName);
        }
        public void GetAddEntryExtractArg_Test(string settingsFile, string presentationRoot)
        {
            presentationRoot = ProgramAssemblyUtility.GetPathFromAssembly(this.GetType().Assembly, presentationRoot);

            var args = new ProgramArgs(new[]
            {
                ProgramArgs.SettingsFile, settingsFile,
                ProgramArgs.BasePath, presentationRoot
            });

            var(presentationInfo, settingsInfo) = args.ToPresentationAndSettingsInfo();

            Assert.True(presentationInfo.Exists);
            Assert.True(settingsInfo.Exists);

            var jO = JObject.Parse(File.ReadAllText(settingsInfo.FullName));

            var entryPath = jO.GetAddEntryExtractArg(presentationInfo);

            Assert.True(File.Exists(entryPath));

            var commandName = jO.GetPublicationCommand();

            Assert.Equal(nameof(MarkdownEntryActivity.AddEntryExtract), commandName);
        }
        public void GetCompressed11tyIndexArgs_Test(string settingsFile, string presentationRoot)
        {
            presentationRoot = ProgramAssemblyUtility.GetPathFromAssembly(this.GetType().Assembly, presentationRoot);

            var args = new ProgramArgs(new[]
            {
                ProgramArgs.SettingsFile, settingsFile,
                ProgramArgs.BasePath, presentationRoot
            });

            var(presentationInfo, settingsInfo) = args.ToPresentationAndSettingsInfo();

            Assert.True(presentationInfo.Exists);
            Assert.True(settingsInfo.Exists);

            var jO = JObject.Parse(File.ReadAllText(settingsInfo.FullName));

            var(entryRootInfo, indexRootInfo, indexFileName) = jO.GetCompressed11tyIndexArgs(presentationInfo);

            Assert.True(entryRootInfo.Exists);
            Assert.True(indexRootInfo.Exists);
            Assert.False(string.IsNullOrWhiteSpace(indexFileName));

            indexRootInfo.FindFile(indexFileName);

            var commandName = jO.GetPublicationCommand();

            Assert.Equal(nameof(SearchIndexActivity.GenerateCompressed11tySearchIndex), commandName);
        }
        public void GetFindChangeArgs_Test(string settingsFile, string presentationRoot)
        {
            presentationRoot = ProgramAssemblyUtility.GetPathFromAssembly(this.GetType().Assembly, presentationRoot);

            var args = new ProgramArgs(new[]
            {
                ProgramArgs.SettingsFile, settingsFile,
                ProgramArgs.BasePath, presentationRoot
            });

            var(presentationInfo, settingsInfo) = args.ToPresentationAndSettingsInfo();

            Assert.True(presentationInfo.Exists);
            Assert.True(settingsInfo.Exists);

            var jO = JObject.Parse(File.ReadAllText(settingsInfo.FullName));

            var(input, pattern, replacement, useRegex, outputPath) = jO.GetFindChangeArgs(presentationInfo);

            Assert.False(string.IsNullOrEmpty(input));
            Assert.False(string.IsNullOrEmpty(pattern));
            Assert.False(string.IsNullOrEmpty(replacement));
            Assert.True(useRegex);
            Assert.False(string.IsNullOrEmpty(outputPath));

            var inputPath = jO.GetValue <string>("inputPath");

            this._testOutputHelper.WriteLine($"{nameof(inputPath)}: {inputPath}");
            this._testOutputHelper.WriteLine($"{nameof(input)}: {input.Substring(0, 16)}...");
            this._testOutputHelper.WriteLine($"{nameof(pattern)}: {pattern}");
            this._testOutputHelper.WriteLine($"{nameof(replacement)}: {replacement}");
            this._testOutputHelper.WriteLine($"{nameof(useRegex)}: {useRegex}");
            this._testOutputHelper.WriteLine($"{nameof(outputPath)}: {outputPath}");
        }
Ejemplo n.º 5
0
        internal void SetContext(ProgramArgs args)
        {
            var(presentationInfo, settingsInfo) = args.ToPresentationAndSettingsInfo();

            this._presentationInfo = presentationInfo;

            traceSource?.TraceVerbose($"applying settings...");
            this._jSettings = JObject.Parse(File.ReadAllText(settingsInfo.FullName));
        }