diff --git a/src/ManiaTemplates/Lib/MtTransformer.cs b/src/ManiaTemplates/Lib/MtTransformer.cs
index ff00ce1..812e9ab 100644
--- a/src/ManiaTemplates/Lib/MtTransformer.cs
+++ b/src/ManiaTemplates/Lib/MtTransformer.cs
@@ -1066,7 +1066,7 @@ private static bool IsStringType(MtComponentProperty property)
///
/// Wraps a string in quotes.
///
- private static string WrapStringInQuotes(string str)
+ public static string WrapStringInQuotes(string str)
{
return $@"$""{str}""";
}
@@ -1140,7 +1140,7 @@ private static XmlNode XmlStringToNode(string content)
///
/// Takes the contents of double curly braces in a string and wraps them into something else. The second Argument takes a string-argument and returns the newly wrapped string.
///
- private static string ReplaceCurlyBraces(string value, Func curlyContentWrapper)
+ public static string ReplaceCurlyBraces(string value, Func curlyContentWrapper)
{
var matches = TemplateInterpolationRegex.Match(value);
var output = value;
diff --git a/tests/ManiaTemplates.Tests/Lib/MtTransformerTest.cs b/tests/ManiaTemplates.Tests/Lib/MtTransformerTest.cs
index e2c75cc..445376e 100644
--- a/tests/ManiaTemplates.Tests/Lib/MtTransformerTest.cs
+++ b/tests/ManiaTemplates.Tests/Lib/MtTransformerTest.cs
@@ -10,9 +10,9 @@ namespace ManiaTemplates.Tests.Lib;
public class MtTransformerTest
{
private readonly ITestOutputHelper _testOutputHelper;
+ private readonly MtTransformer _transformer;
private readonly ManiaTemplateEngine _maniaTemplateEngine = new();
private readonly Regex _hashCodePattern = new("[0-9]{6,10}");
-
private readonly MtComponent _testComponent = new()
{
Namespaces = new() { "namespace" },
@@ -47,8 +47,6 @@ public class MtTransformerTest
"
};
- private readonly MtTransformer _transformer;
-
public MtTransformerTest(ITestOutputHelper testOutputHelper)
{
_testOutputHelper = testOutputHelper;
@@ -90,9 +88,9 @@ public void Should_Build_Manialink()
var expected = File.ReadAllText("Lib/expected.tt");
var result = _transformer.BuildManialink(_testComponent, "expected");
var generalizedResult = TransformCodeToOrderNumber(result);
-
+
_testOutputHelper.WriteLine(generalizedResult);
-
+
Assert.Equal(expected, generalizedResult, ignoreLineEndingDifferences: true);
}
@@ -118,15 +116,33 @@ public void Should_Import_Components_Recursively()
{
var assemblies = new List();
assemblies.Add(Assembly.GetExecutingAssembly());
-
+
_maniaTemplateEngine.AddTemplateFromString("Embeddable", "");
- _maniaTemplateEngine.AddTemplateFromString("RecursionElement", "");
- _maniaTemplateEngine.AddTemplateFromString("RecursionRoot", "");
-
- var output = _maniaTemplateEngine.RenderAsync("RecursionRoot", new {}, assemblies).Result;
- Assert.Equal( @$"
+ _maniaTemplateEngine.AddTemplateFromString("RecursionElement",
+ "");
+ _maniaTemplateEngine.AddTemplateFromString("RecursionRoot",
+ "");
+
+ var output = _maniaTemplateEngine.RenderAsync("RecursionRoot", new { }, assemblies).Result;
+ Assert.Equal(@$"
", output, ignoreLineEndingDifferences: true);
}
+
+ [Fact]
+ public void Should_Replace_Curly_Braces_Correctly()
+ {
+ Assert.Equal("abcd", MtTransformer.ReplaceCurlyBraces("{{a}}{{ b }}{{c }}{{ d}}", s => s));
+ Assert.Equal("x y z", MtTransformer.ReplaceCurlyBraces("{{x}} {{ y }} {{z }}", s => s));
+ Assert.Equal("unittest", MtTransformer.ReplaceCurlyBraces("{{ unit }}test", s => s));
+ Assert.Equal("#unit#test", MtTransformer.ReplaceCurlyBraces("{{ unit }}test", s => $"#{s}#"));
+ Assert.Equal("#{ unit#}test", MtTransformer.ReplaceCurlyBraces("{{{ unit }}}test", s => $"#{s}#"));
+ }
+
+ [Fact]
+ public void Should_Wrap_Strings_In_Quotes()
+ {
+ Assert.Equal(@"$""unit test""", MtTransformer.WrapStringInQuotes("unit test"));
+ }
}
\ No newline at end of file