public void TestPolymorphicTemplateReference()
{
string dir1 = Path.Combine(tmpdir, "d1");
string b = "b() ::= <<dir1 b>>\n";
writeFile(dir1, "b.st", b);
string dir2 = Path.Combine(tmpdir, "d2");
string a = "a() ::= << <b()> >>\n";
b = "b() ::= <<dir2 b>>\n";
writeFile(dir2, "a.st", a);
writeFile(dir2, "b.st", b);
TemplateGroup group1 = new TemplateGroupDirectory(dir1);
TemplateGroup group2 = new TemplateGroupDirectory(dir2);
group1.ImportTemplates(group2);
// normal lookup; a created from dir2 calls dir2.b
Template st = group2.GetInstanceOf("a");
string expected = " dir2 b ";
string result = st?.Render();
Assert.AreEqual(expected, result);
// polymorphic lookup; a created from dir1 calls dir2.a which calls dir1.b
st = group1.GetInstanceOf("a");
expected = " dir1 b ";
result = st?.Render();
Assert.AreEqual(expected, result);
}