public async Task ThrowForNoSourceWhenIncludingRelativePath() { // Given TestExecutionContext context = GetExecutionContext(); TestDocument document = new TestDocument("foo ^\"test-a.txt\" bar"); ProcessIncludes include = new ProcessIncludes(); // When, Then await Should.ThrowAsync <Exception>(async() => await ExecuteAsync(document, context, include)); }
public async Task MultipleIncludes() { // Given TestExecutionContext context = GetExecutionContext(); TestDocument document = new TestDocument(new FilePath("/TestFiles/Input/test.txt"), "x ^\"test-a.txt\" y ^\"test-b.txt\" z"); ProcessIncludes include = new ProcessIncludes(); // When TestDocument result = await ExecuteAsync(document, context, include).SingleAsync(); // Then result.Content.ShouldBe("x aaa y bbb z"); }
public async Task DoesNotIncludeOnFirstCharacterIfEscaped() { // Given TestExecutionContext context = GetExecutionContext(); TestDocument document = new TestDocument(new FilePath("/TestFiles/Input/test.txt"), "\\^\"test-a.txt\"foo"); ProcessIncludes include = new ProcessIncludes(); // When TestDocument result = await ExecuteAsync(document, context, include).SingleAsync(); // Then result.Content.ShouldBe("^\"test-a.txt\"foo"); }
public async Task DoesNotThrowForNoSourceWhenIncludingAbsolutePath() { // Given TestExecutionContext context = GetExecutionContext(); TestDocument document = new TestDocument("foo ^\"/TestFiles/Input/test-a.txt\" bar"); ProcessIncludes include = new ProcessIncludes(); // When, Then TestDocument result = await ExecuteAsync(document, context, include).SingleAsync(); // Then result.Content.ShouldBe("foo aaa bar"); }
public async Task IncludingAbsolutePath() { // Given TestExecutionContext context = GetExecutionContext(); TestDocument document = new TestDocument(new FilePath("/TestFiles/Input/test.txt"), "x ^\"/TestFiles/test-above-input.txt\" y"); ProcessIncludes include = new ProcessIncludes(); // When TestDocument result = await ExecuteAsync(document, context, include).SingleAsync(); // Then result.Content.ShouldBe("x test y"); }
public async Task MultipleEscapeCharacters() { // Given TestExecutionContext context = GetExecutionContext(); TestDocument document = new TestDocument(new NormalizedPath("/TestFiles/Input/test.txt"), "\\\\\\^\"test-a.txt\"foo"); ProcessIncludes include = new ProcessIncludes(); // When TestDocument result = await ExecuteAsync(document, context, include).SingleAsync(); // Then result.Content.ShouldBe("\\\\^\"test-a.txt\"foo"); }
public async Task IncludingRelativePath() { // Given TestExecutionContext context = GetExecutionContext(); TestDocument document = new TestDocument(new NormalizedPath("/TestFiles/Input/test.txt"), "x ^\"Subfolder/test-c.txt\" y"); ProcessIncludes include = new ProcessIncludes(); // When TestDocument result = await ExecuteAsync(document, context, include).SingleAsync(); // Then result.Content.ShouldBe("x ccc y"); }
public async Task FileNotFoundRemovesIncludeStatement() { // Given TestExecutionContext context = GetExecutionContext(); context.Logger = new TestLogger(LogLevel.Error); TestDocument document = new TestDocument(new FilePath("/TestFiles/Input/test.txt"), "x ^\"test-c.txt\" y"); ProcessIncludes include = new ProcessIncludes(); // When TestDocument result = await ExecuteAsync(document, context, include).SingleAsync(); // Then result.Content.ShouldBe("x y"); }
public async Task NestedIncludeWithInnerEscape() { // Given TestExecutionContext context = GetExecutionContext(out TestFileProvider fileProvider); fileProvider.AddFile( "/TestFiles/Input/test-outer.txt", "3 \\^\"test-a.txt\" 4"); TestDocument document = new TestDocument(new FilePath("/TestFiles/Input/test.txt"), "1 ^\"test-outer.txt\" 2"); ProcessIncludes include = new ProcessIncludes().WithRecursion(false); // When TestDocument result = await ExecuteAsync(document, context, include).SingleAsync(); // Then result.Content.ShouldBe("1 3 \\^\"test-a.txt\" 4 2"); }
public async Task MultipleNestedInclude() { // Given TestExecutionContext context = GetExecutionContext(out TestFileProvider fileProvider); fileProvider.AddFile( "/TestFiles/Input/test-outer.txt", "3 ^\"test-inner.txt\" 4"); fileProvider.AddFile( "/TestFiles/Input/test-inner.txt", "5 ^\"test-a.txt\" 6"); TestDocument document = new TestDocument(new FilePath("/TestFiles/Input/test.txt"), "1 ^\"test-outer.txt\" 2"); ProcessIncludes include = new ProcessIncludes(); // When TestDocument result = await ExecuteAsync(document, context, include).SingleAsync(); // Then result.Content.ShouldBe("1 3 5 aaa 6 4 2"); }