-
-
Notifications
You must be signed in to change notification settings - Fork 74
/
TemplateManagerTests.cs
71 lines (63 loc) · 2.03 KB
/
TemplateManagerTests.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
using System.Collections;
using Cottle;
using SuchByte.MacroDeck.CottleIntegration;
namespace MacroDeck.Tests;
[TestFixture]
internal class TemplateManagerTests
{
[Test]
public void AllKeywords_Contains_NoNulls()
{
Assert.That(TemplateManager.AllKeywords, Has.No.Null.Or.Empty);
}
[Test]
public void AllKeywords_Length_IsEqualTo_Content()
{
var contentLength = TemplateManager.AllKeywords.Count(x => !string.IsNullOrEmpty(x));
Assert.That(TemplateManager.AllKeywords, Has.Length.EqualTo(contentLength));
}
[Test]
public void AllKeywords_Length_IsEqualTo_ArrayLengths()
{
var expectedLength = TemplateManager.Commands.Length +
TemplateManager.Functions.Length +
TemplateManager.Operators.Length +
TemplateManager.Special.Length +
TemplateManager.MacroDeckFunctions.Length;
Assert.That(TemplateManager.AllKeywords, Has.Length.EqualTo(expectedLength));
}
[TestCaseSource(typeof(TemplateManagerTestData), nameof(TemplateManagerTestData.Templates))]
public string Render_Templates_NoDb(string template)
{
var doc = TemplateManager.GetDocument(template);
return doc.Render(Context.CreateBuiltin(Context.Empty));
}
}
public class TemplateManagerTestData
{
public static IEnumerable Templates
{
get
{
yield return new TestCaseData("""
{ "these "}
{ "are "}
{ "words "}
{ "on "}
{ "new "}
{ "lines."}
""")
.Returns("these \r\nare \r\nwords \r\non \r\nnew \r\nlines."); //note spacing and new lines
yield return new TestCaseData("""
_trimblank_
{ "these "}
{ "are "}
{ "words "}
{ "on "}
{ "new "}
{ "lines."}
""")
.Returns("these are words on new lines.");
}
}
}