public void TestLgFileImportMultipleTimes() { var engine = new TemplateEngine().AddFiles(new List <string>() { GetExampleFilePath("import.lg"), GetExampleFilePath("import2.lg") }); // Assert 6.lg is imported only once and no exceptions are thrown when it is imported from multiple files. Assert.AreEqual(14, engine.Templates.Count()); string evaled = engine.EvaluateTemplate("basicTemplate", null).ToString(); Assert.IsTrue(evaled == "Hi" || evaled == "Hello"); evaled = engine.EvaluateTemplate("welcome", null).ToString(); Assert.IsTrue(evaled == "Hi DongLei :)" || evaled == "Hey DongLei :)" || evaled == "Hello DongLei :)"); evaled = engine.EvaluateTemplate("welcome", new { userName = "******" }).ToString(); Assert.IsTrue(evaled == "Hi DL :)" || evaled == "Hey DL :)" || evaled == "Hello DL :)"); evaled = engine.EvaluateTemplate("basicTemplate2", null).ToString(); Assert.IsTrue(evaled == "Hi 2" || evaled == "Hello 2"); evaled = engine.EvaluateTemplate("basicTemplate3", null).ToString(); Assert.IsTrue(evaled == "Hi" || evaled == "Hello"); evaled = engine.EvaluateTemplate("basicTemplate4", null).ToString(); Assert.IsTrue(evaled == "Hi 2" || evaled == "Hello 2"); engine = new TemplateEngine().AddFile(GetExampleFilePath("import.lg")); var ex = Assert.ThrowsException <Exception>(() => engine.AddFile(GetExampleFilePath("import2.lg"))); Assert.IsTrue(ex.Message.Contains("Duplicated definitions found for template: wPhrase")); engine = new TemplateEngine().AddFiles(new List <string>() { GetExampleFilePath("import.lg") }); ex = Assert.ThrowsException <Exception>(() => engine.AddFiles(new List <string>() { GetExampleFilePath("import2.lg") })); Assert.IsTrue(ex.Message.Contains("Duplicated definitions found for template: wPhrase")); }