当前位置: 首页>>代码示例>>C#>>正文


C# ExecutionContext.GetDocument方法代码示例

本文整理汇总了C#中ExecutionContext.GetDocument方法的典型用法代码示例。如果您正苦于以下问题:C# ExecutionContext.GetDocument方法的具体用法?C# ExecutionContext.GetDocument怎么用?C# ExecutionContext.GetDocument使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ExecutionContext的用法示例。


在下文中一共展示了ExecutionContext.GetDocument方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DefaultCtorIgnoresDelimiterOnFirstLine

            public void DefaultCtorIgnoresDelimiterOnFirstLine()
            {
                // Given
                Engine engine = new Engine();
                Pipeline pipeline = new Pipeline("Pipeline", null);
                IExecutionContext context = new ExecutionContext(engine, pipeline);
                IDocument[] inputs =
                {
                    context.GetDocument(@"---
                FM1
                FM2
                ---
                Content1
                Content2")
                };
                string frontMatterContent = null;
                FrontMatter frontMatter = new FrontMatter(new Execute((x, ctx) =>
                {
                    frontMatterContent = x.Content;
                    return new[] {x};
                }));

                // When
                IEnumerable<IDocument> documents = frontMatter.Execute(inputs, context);

                // Then
                Assert.AreEqual(1, documents.Count());
                Assert.AreEqual(@"FM1
                FM2
                ", frontMatterContent);
                Assert.AreEqual(@"Content1
                Content2", documents.First().Content);
            }
开发者ID:ryanrousseau,项目名称:Wyam,代码行数:33,代码来源:FrontMatterTests.cs

示例2: DashStringDoesNotSplitAtNonmatchingDashes

            public void DashStringDoesNotSplitAtNonmatchingDashes()
            {
                // Given
                Engine engine = new Engine();
                Pipeline pipeline = new Pipeline("Pipeline", null);
                IExecutionContext context = new ExecutionContext(engine, pipeline);
                IDocument[] inputs =
                {
                    context.GetDocument(@"FM1
                FM2
                ---
                Content1
                Content2")
                };
                bool executed = false;
                FrontMatter frontMatter = new FrontMatter("-", new Execute((x, ctx) =>
                {
                    executed = true;
                    return new[] {x};
                }));

                // When
                IEnumerable<IDocument> documents = frontMatter.Execute(inputs, context);

                // Then
                Assert.AreEqual(1, documents.Count());
                Assert.IsFalse(executed);
                Assert.AreEqual(@"FM1
                FM2
                ---
                Content1
                Content2", documents.First().Content);
            }
开发者ID:ryanrousseau,项目名称:Wyam,代码行数:33,代码来源:FrontMatterTests.cs

示例3: SetUp

 public void SetUp()
 {
     Engine = new Engine();
     Engine.FileSystem.FileProviders.Add(NormalizedPath.DefaultFileProvider.Scheme, GetFileProvider());
     Engine.FileSystem.RootPath = "/";
     Engine.FileSystem.InputPaths.Clear();
     Engine.FileSystem.InputPaths.Add("/TestFiles/Input");
     Pipeline = new Pipeline("Pipeline", null);
     Context = new ExecutionContext(Engine, Pipeline);
     Inputs = new [] { Context.GetDocument() };
 }
开发者ID:ibebbs,项目名称:Wyam,代码行数:11,代码来源:ReadFilesTests.cs

示例4: ExecuteGetsCorrectContent

            public void ExecuteGetsCorrectContent()
            {
                // Given
                Engine engine = new Engine();
                engine.RootFolder = TestContext.CurrentContext.TestDirectory;
                engine.InputFolder = @"TestFiles\Input";
                Pipeline pipeline = new Pipeline("Pipeline", null);
                IExecutionContext context = new ExecutionContext(engine, pipeline);
                IDocument[] inputs = { context.GetDocument() };
                ReadFiles readFiles = new ReadFiles(@"test-a.txt");

                // When
                IDocument document = readFiles.Execute(inputs, context).First();

                // Then
                Assert.AreEqual("aaa", document.Content);
            }
开发者ID:ryanrousseau,项目名称:Wyam,代码行数:17,代码来源:ReadFilesTests.cs

示例5: FileNameIsConvertedCorrectly

            public void FileNameIsConvertedCorrectly(string input, string output)
            {
                // Given
                Engine engine = new Engine();
                Pipeline pipeline = new Pipeline("Pipeline", null);
                IExecutionContext context = new ExecutionContext(engine, pipeline);
                IDocument[] inputs = { context.GetDocument(new MetadataItems
                {
                    new MetadataItem(Keys.SourceFileName, input)
                }) };
                FileName fileName = new FileName();

                // When
                IEnumerable<IDocument> documents = fileName.Execute(inputs, context);

                // Then
                Assert.AreEqual(output, documents.First().FilePath(Keys.WriteFileName).FullPath);
            }
开发者ID:ibebbs,项目名称:Wyam,代码行数:18,代码来源:FileNameTests.cs

示例6: FileNameIsConvertedCorrectlyWithReservedChar

            public void FileNameIsConvertedCorrectlyWithReservedChar(string character)
            {
                // Given
                Engine engine = new Engine();
                Pipeline pipeline = new Pipeline("Pipeline", null);
                IExecutionContext context = new ExecutionContext(engine, pipeline);
                string manyCharactersWow = new String(character[0], 10);
                IDocument[] inputs = { context.GetDocument(new MetadataItems
                {
                    new MetadataItem(Keys.SourceFileName,
                        string.Format("testing {0} some of {0} these {0}", manyCharactersWow))
                }) };
                FileName fileName = new FileName();

                // When
                IEnumerable<IDocument> documents = fileName.Execute(inputs, context);

                // Then
                Assert.AreEqual("testing-some-of-these-", documents.First()[Keys.WriteFileName]);
            }
开发者ID:ryanrousseau,项目名称:Wyam,代码行数:20,代码来源:FileNameTests.cs

示例7: FileNameShouldBeLowercase

		    public void FileNameShouldBeLowercase()
		    {
			    // Given
			    string input = "FileName With MiXeD CapS";
			    string output = "filename-with-mixed-caps";

                Engine engine = new Engine();
			    Pipeline pipeline = new Pipeline("Pipeline", null);
			    IExecutionContext context = new ExecutionContext(engine, pipeline);
			    IDocument[] inputs = { context.GetDocument(new MetadataItems
			    {
                    new MetadataItem(Keys.SourceFileName, new FilePath(input))
			    }) };
			    FileName fileName = new FileName();

			    // When
			    IEnumerable<IDocument> documents = fileName.Execute(inputs, context);

			    // Then
			    Assert.AreEqual(output, documents.First().FilePath(Keys.WriteFileName).FullPath);
		    }
开发者ID:ibebbs,项目名称:Wyam,代码行数:21,代码来源:FileNameTests.cs

示例8: WithAllowedCharactersDoesNotReplaceProvidedCharacters

		    public void WithAllowedCharactersDoesNotReplaceProvidedCharacters()
		    {
			    // Given
			    string input = "this-is-a-.net-tag";
			    string output = "this-is-a-.net-tag";

			    Engine engine = new Engine();
			    Pipeline pipeline = new Pipeline("Pipeline", null);
			    IExecutionContext context = new ExecutionContext(engine, pipeline);
			    IDocument[] inputs = { context.GetDocument(new MetadataItems
			    {
                    new MetadataItem(Keys.SourceFileName, new FilePath(input))
			    }) };
			    FileName fileName = new FileName();

			    // When
			    fileName = fileName.WithAllowedCharacters(new string[] { "-" });
			    IEnumerable<IDocument> documents = fileName.Execute(inputs, context);

			    // Then
			    Assert.AreEqual(output, documents.First().FilePath(Keys.WriteFileName).FullPath);
            }
开发者ID:ibebbs,项目名称:Wyam,代码行数:22,代码来源:FileNameTests.cs

示例9: TrimWhitespace

            public void TrimWhitespace()
            {
                // Given
                string input = "   myfile.html   ";
                string output = "myfile.html";

                Engine engine = new Engine();
                Pipeline pipeline = new Pipeline("Pipeline", null);
                IExecutionContext context = new ExecutionContext(engine, pipeline);
                IDocument[] inputs =
                {
                    context.GetDocument(new MetadataItems
                    {
                        new MetadataItem("MyKey", input)
                    })
                };
                FileName fileName = new FileName("MyKey");

                // When
                IEnumerable<IDocument> documents = fileName.Execute(inputs, context);

                // Then
                Assert.AreEqual(output, documents.First().FilePath(Keys.WriteFileName).FullPath);
            }
开发者ID:ibebbs,项目名称:Wyam,代码行数:24,代码来源:FileNameTests.cs

示例10: IgnoresNullOrWhiteSpaceStrings

            public void IgnoresNullOrWhiteSpaceStrings(string input)
            {
                // Given
                Engine engine = new Engine();
                Pipeline pipeline = new Pipeline("Pipeline", null);
                IExecutionContext context = new ExecutionContext(engine, pipeline);
                IDocument[] inputs = { context.GetDocument(new MetadataItems
                {
                    new MetadataItem(Keys.SourceFileName, input)
                }) };
                FileName fileName = new FileName();

                // When
                IEnumerable<IDocument> documents = fileName.Execute(inputs, context);

                // Then
                Assert.IsFalse(documents.First().ContainsKey(Keys.WriteFileName));
            }
开发者ID:ibebbs,项目名称:Wyam,代码行数:18,代码来源:FileNameTests.cs

示例11: SearchPatternFindsCorrectFiles

            public void SearchPatternFindsCorrectFiles(string searchPattern, SearchOption searchOption,
                int expectedCount)
            {
                // Given
                Engine engine = new Engine();
                engine.RootFolder = TestContext.CurrentContext.TestDirectory;
                engine.InputFolder = @"TestFiles\Input\";
                Pipeline pipeline = new Pipeline("Pipeline", null);
                IExecutionContext context = new ExecutionContext(engine, pipeline);
                IDocument[] inputs = { context.GetDocument() };
                ReadFiles readFiles = new ReadFiles(searchPattern).WithSearchOption(searchOption);

                // When
                IEnumerable<IDocument> documents = readFiles.Execute(inputs, context);
                int count = documents.Count();

                // Then
                Assert.AreEqual(expectedCount, count);
            }
开发者ID:ryanrousseau,项目名称:Wyam,代码行数:19,代码来源:ReadFilesTests.cs

示例12: SingleCharWithSingleDelimiterSplitsAtCorrectLocation

            public void SingleCharWithSingleDelimiterSplitsAtCorrectLocation()
            {
                // Given
                Engine engine = new Engine();
                Pipeline pipeline = new Pipeline("Pipeline", null);
                IExecutionContext context = new ExecutionContext(engine, pipeline);
                IDocument[] inputs =
                {
                    context.GetDocument(@"FM1
                FM2
                !
                Content1
                Content2")
                };
                string frontMatterContent = null;
                FrontMatter frontMatter = new FrontMatter('!', new Execute((x, ctx) =>
                {
                    frontMatterContent = x.Content;
                    return new[] {x};
                }));

                // When
                IEnumerable<IDocument> documents = frontMatter.Execute(inputs, context);

                // Then
                Assert.AreEqual(1, documents.Count());
                Assert.AreEqual(@"FM1
                FM2
                ", frontMatterContent);
                Assert.AreEqual(@"Content1
                Content2", documents.First().Content);
            }
开发者ID:ryanrousseau,项目名称:Wyam,代码行数:32,代码来源:FrontMatterTests.cs

示例13: SingleCharWithRepeatedDelimiterWithLeadingSpacesDoesNotSplit

            public void SingleCharWithRepeatedDelimiterWithLeadingSpacesDoesNotSplit()
            {
                // Given
                Engine engine = new Engine();
                Pipeline pipeline = new Pipeline("Pipeline", null);
                IExecutionContext context = new ExecutionContext(engine, pipeline);
                IDocument[] inputs =
                {
                    context.GetDocument(@"FM1
                FM2
                  !!!!
                Content1
                Content2")
                };
                bool executed = false;
                FrontMatter frontMatter = new FrontMatter('!', new Execute((x, ctx) =>
                {
                    executed = true;
                    return new[] {x};
                }));

                // When
                IEnumerable<IDocument> documents = frontMatter.Execute(inputs, context);

                // Then
                Assert.AreEqual(1, documents.Count());
                Assert.IsFalse(executed);
                Assert.AreEqual(@"FM1
                FM2
                  !!!!
                Content1
                Content2", documents.First().Content);
            }
开发者ID:ryanrousseau,项目名称:Wyam,代码行数:33,代码来源:FrontMatterTests.cs

示例14: MultipleInputDocumentsResultsInMultipleOutputs

            public void MultipleInputDocumentsResultsInMultipleOutputs()
            {
                // Given
                Engine engine = new Engine();
                Pipeline pipeline = new Pipeline("Pipeline", null);
                IExecutionContext context = new ExecutionContext(engine, pipeline);
                IDocument[] inputs =
                {
                    context.GetDocument(@"AA
                -
                XX"),
                    context.GetDocument(@"BB
                -
                YY")
                };
                string frontMatterContent = string.Empty;
                FrontMatter frontMatter = new FrontMatter(new Execute((x, ctx) =>
                {
                    frontMatterContent += x.Content;
                    return new[] {x};
                }));

                // When
                IEnumerable<IDocument> documents = frontMatter.Execute(inputs, context);

                // Then
                Assert.AreEqual(2, documents.Count());
                Assert.AreEqual(@"AA
                BB
                ", frontMatterContent);
                Assert.AreEqual(@"XX", documents.First().Content);
                Assert.AreEqual(@"YY", documents.Skip(1).First().Content);
            }
开发者ID:ryanrousseau,项目名称:Wyam,代码行数:33,代码来源:FrontMatterTests.cs

示例15: ReadFilesSetsMetadata

            public void ReadFilesSetsMetadata(string key, string expectedEnding)
            {
                // Given
                Engine engine = new Engine();
                engine.RootFolder = TestContext.CurrentContext.TestDirectory;
                engine.InputFolder = @"TestFiles\Input";
                Pipeline pipeline = new Pipeline("Pipeline", null);
                IExecutionContext context = new ExecutionContext(engine, pipeline);
                IDocument[] inputs = { context.GetDocument() };
                ReadFiles readFiles = new ReadFiles(@"test-c.txt");

                // When
                IDocument output = readFiles.Execute(inputs, context).First();
                foreach (IDocument document in inputs)
                {
                    ((IDisposable) document).Dispose();
                }

                // Then
                Assert.That(output.Metadata[key], Does.EndWith(expectedEnding));
                ((IDisposable) output).Dispose();
            }
开发者ID:ryanrousseau,项目名称:Wyam,代码行数:22,代码来源:ReadFilesTests.cs


注:本文中的ExecutionContext.GetDocument方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。