public void LoadLayoutFile() { // Given Engine engine = new Engine(); engine.InputFolder = @"TestFiles\Input\"; ReadFiles readFiles = new ReadFiles(@"Layout\Test.cshtml"); Razor razor = new Razor(); engine.Pipelines.Add("Pipeline", readFiles, razor); // When engine.Execute(); // Then Assert.AreEqual(1, engine.Documents.FromPipeline("Pipeline").Count()); Assert.AreEqual("LAYOUT\r\n\r\n<p>This is a test</p>", engine.Documents.FromPipeline("Pipeline").First().Content); }
public void AlternateIgnorePrefix() { // Given Engine engine = new Engine(); engine.InputFolder = @"TestFiles\Input\"; ReadFiles readFiles = new ReadFiles(@"AlternateIgnorePrefix\*.cshtml"); Razor razor = new Razor().IgnorePrefix("Ignore"); engine.Pipelines.Add("Pipeline", readFiles, razor); // When engine.Execute(); // Then Assert.AreEqual(1, engine.Documents.FromPipeline("Pipeline").Count()); Assert.AreEqual(@"<p>This is a test</p>", engine.Documents.FromPipeline("Pipeline").First().Content); }
public void IgnoresUnderscoresByDefault() { // Given Engine engine = new Engine(); engine.InputFolder = @"TestFiles\Input\"; ReadFiles readFiles = new ReadFiles(@"IgnoreUnderscores\*.cshtml"); Razor razor = new Razor(); Meta meta = new Meta("Content", (x, y) => x.Content); engine.Pipelines.Add("Pipeline", readFiles, razor, meta); // When engine.Execute(); // Then Assert.AreEqual(1, engine.Documents.FromPipeline("Pipeline").Count()); Assert.AreEqual("LAYOUT\r\n\r\n<p>This is a test</p>", engine.Documents.FromPipeline("Pipeline").First().String("Content")); }
public void AlternateViewStartPath() { // Given Engine engine = new Engine(); engine.InputFolder = @"TestFiles\Input\"; ReadFiles readFiles = new ReadFiles(@"AlternateViewStartPath\Test.cshtml"); Razor razor = new Razor().WithViewStart(@"AlternateViewStart\_ViewStart.cshtml"); Meta meta = new Meta("Content", (x, y) => x.Content); engine.Pipelines.Add("Pipeline", readFiles, razor, meta); // When engine.Execute(); // Then Assert.AreEqual(1, engine.Documents.FromPipeline("Pipeline").Count()); Assert.AreEqual("LAYOUT\r\n<p>This is a test</p>", engine.Documents.FromPipeline("Pipeline").First().String("Content")); }
public void PrepareSetsMetadata(string key, string expectedEnding) { // Given Engine engine = new Engine(); engine.InputFolder = @"TestFiles\Input"; Metadata metadata = new Metadata(engine); IDocument[] inputs = { new Document(metadata) }; Pipeline pipeline = new Pipeline("Pipeline", engine, null); IExecutionContext context = new ExecutionContext(engine, pipeline); ReadFiles readFiles = new ReadFiles(@"test-c.txt"); // When IDocument document = readFiles.Execute(inputs, context).First(); // Then Assert.That(document.Metadata[key], Is.StringEnding(expectedEnding)); }
public void ExecuteGetsCorrectContent() { // Given Engine engine = new Engine(); engine.InputFolder = @"TestFiles\Input"; Metadata metadata = new Metadata(engine); IDocument[] inputs = { new Document(metadata) }; Pipeline pipeline = new Pipeline("Pipeline", engine, null); IExecutionContext context = new ExecutionContext(engine, pipeline); ReadFiles readFiles = new ReadFiles(@"test-a.txt"); // When IDocument document = readFiles.Execute(inputs, context).First(); // Then Assert.AreEqual("aaa", document.Content); }
public void SearchPatternFindsCorrectFiles(string searchPattern, SearchOption searchOption, int expectedCount) { // Given Engine engine = new Engine(); engine.InputFolder = @"TestFiles\Input\"; Metadata metadata = new Metadata(engine); IDocument[] inputs = { new Document(metadata) }; Pipeline pipeline = new Pipeline("Pipeline", engine, null); IExecutionContext context = new ExecutionContext(engine, pipeline); ReadFiles readFiles = new ReadFiles(searchPattern).SearchOption(searchOption); // When IEnumerable<IDocument> documents = readFiles.Execute(inputs, context); int count = documents.Count(); // Then Assert.AreEqual(expectedCount, count); }
public void SearchPatternWorksWithInputPathTrailingSlash() { // Given Engine engine = new Engine(); engine.Trace.AddListener(new TestTraceListener()); engine.InputFolder = @"TestFiles\Input"; Metadata metadata = new Metadata(engine); Pipeline pipeline = new Pipeline("Pipeline", engine, null); IDocument[] inputs = { new Document(metadata, pipeline) }; IExecutionContext context = new ExecutionContext(engine, pipeline); ReadFiles readFiles = new ReadFiles("*.txt"); // When IEnumerable<IDocument> documents = readFiles.Execute(inputs, context); int count = documents.Count(); // Then Assert.AreEqual(3, count); }
public void RenderLayoutSectionOnMultipleExecution() { // Given Engine engine = new Engine(); engine.InputFolder = @"TestFiles\Input\"; ReadFiles readFiles = new ReadFiles(@"LayoutWithSection\Test.cshtml"); Razor razor = new Razor(); Meta meta = new Meta("Content", (x, y) => x.Content); engine.Pipelines.Add("Pipeline", readFiles, razor, meta); // When engine.Execute(); engine.Execute(); // Then Assert.AreEqual(1, engine.Documents.FromPipeline("Pipeline").Count()); Assert.AreEqual("LAYOUT\r\n\r\n<p>Section Content</p>\r\n\r\n\r\n<p>This is a test</p>", engine.Documents.FromPipeline("Pipeline").First().String("Content")); }
public void LoadSimpleTemplateFile() { // Given Engine engine = new Engine(); engine.InputFolder = @"TestFiles\Input\"; ReadFiles readFiles = new ReadFiles(@"SimpleTemplate\Test.cshtml"); Razor razor = new Razor(); Meta meta = new Meta("Content", (x, y) => x.Content); engine.Pipelines.Add("Pipeline", readFiles, razor, meta); // When engine.Execute(); // Then Assert.AreEqual(1, engine.Documents.FromPipeline("Pipeline").Count()); Assert.AreEqual(@"<p>This is a test</p>", engine.Documents.FromPipeline("Pipeline").First().String("Content")); }
public void SearchPatternWorksWithSubpath() { // Given Engine engine = new Engine(); engine.InputFolder = @"TestFiles\Input"; Metadata metadata = new Metadata(engine); IDocument[] inputs = { new Document(metadata) }; Pipeline pipeline = new Pipeline("Pipeline", engine, null); IExecutionContext context = new ExecutionContext(engine, pipeline); ReadFiles readFiles = new ReadFiles(@"Subfolder\*.txt"); // When IEnumerable<IDocument> documents = readFiles.Execute(inputs, context); int count = documents.Count(); // Then Assert.AreEqual(1, count); }
public void WithExtensionsWorksWithoutDotPrefix() { // Given Engine engine = new Engine(); engine.Trace.AddListener(new TestTraceListener()); engine.InputFolder = @"TestFiles\Input"; Metadata metadata = new Metadata(engine); Pipeline pipeline = new Pipeline("Pipeline", engine, null); IDocument[] inputs = { new Document(metadata, pipeline) }; IExecutionContext context = new ExecutionContext(engine, pipeline); ReadFiles readFiles = new ReadFiles("*.*").WithExtensions("txt", "md"); // When IEnumerable<IDocument> documents = readFiles.Execute(inputs, context); int count = documents.Count(); // Then Assert.AreEqual(5, count); }
public void WhereGetsCorrectFiles() { // Given Engine engine = new Engine(); engine.Trace.AddListener(new TestTraceListener()); engine.InputFolder = @"TestFiles\Input"; Metadata metadata = new Metadata(engine); Pipeline pipeline = new Pipeline("Pipeline", engine, null); IDocument[] inputs = { new Document(metadata, pipeline) }; IExecutionContext context = new ExecutionContext(engine, pipeline); ReadFiles readFiles = new ReadFiles("*.*").Where(x => x.Contains("test")); // When IEnumerable<IDocument> documents = readFiles.Execute(inputs, context); int count = documents.Count(); // Then Assert.AreEqual(3, count); }