-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathCodeTests.cs
48 lines (40 loc) · 1.38 KB
/
CodeTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
using Elastic.Markdown.Myst.CodeBlocks;
using Elastic.Markdown.Tests.Inline;
using FluentAssertions;
namespace Elastic.Markdown.Tests.CodeBlocks;
public abstract class CodeBlockTests(ITestOutputHelper output, string directive, string? language = null)
: BlockTest<EnhancedCodeBlock>(output,
$$"""
```{{directive}} {{language}}
var x = 1;
```
A regular paragraph.
"""
)
{
[Fact]
public void ParsesAdmonitionBlock() => Block.Should().NotBeNull();
}
public class CodeBlockDirectiveTests(ITestOutputHelper output) : CodeBlockTests(output, "{code-block}", "csharp")
{
[Fact]
public void SetsLanguage() => Block!.Language.Should().Be("csharp");
}
public class CodeTests(ITestOutputHelper output) : CodeBlockTests(output, "{code}", "python")
{
[Fact]
public void SetsLanguage() => Block!.Language.Should().Be("python");
}
public class SourceCodeTests(ITestOutputHelper output) : CodeBlockTests(output, "{sourcecode}", "java")
{
[Fact]
public void SetsLanguage() => Block!.Language.Should().Be("java");
}
public class RawMarkdownCodeBlockTests(ITestOutputHelper output) : CodeBlockTests(output, "javascript")
{
[Fact]
public void SetsLanguage() => Block!.Language.Should().Be("javascript");
}