public void AddManagerDeclarationToExistingDeclarationSection() { JObject rootNode = new JObject(); rootNode["Code"] = "using System;" + Environment.NewLine + "namespace Models" + Environment.NewLine + "{" + Environment.NewLine + " [Serializable]" + Environment.NewLine + " public class Script : Model" + Environment.NewLine + " {" + Environment.NewLine + " [Link]" + Environment.NewLine + " A B;" + Environment.NewLine + " }" + Environment.NewLine + "}" + Environment.NewLine; var manager = new ManagerConverter(rootNode); manager.AddDeclaration("NutrientPool", "Humic", new string[] { "[Link]" }); // Ensure the link has been added below the using statement. Assert.AreEqual(manager.ToString(), "using System;" + Environment.NewLine + "namespace Models" + Environment.NewLine + "{" + Environment.NewLine + " [Serializable]" + Environment.NewLine + " public class Script : Model" + Environment.NewLine + " {" + Environment.NewLine + " [Link]" + Environment.NewLine + " private A B;" + Environment.NewLine + " [Link]" + Environment.NewLine + " private NutrientPool Humic;" + Environment.NewLine + " }" + Environment.NewLine + "}" + Environment.NewLine); }
public void AddManagerDeclarationHandleProperties() { JObject rootNode = new JObject(); rootNode["Code"] = "using System;" + Environment.NewLine + "namespace Models" + Environment.NewLine + "{" + Environment.NewLine + " [Serializable]" + Environment.NewLine + " public class Script : Model" + Environment.NewLine + " {" + Environment.NewLine + " [Link] private A B = null;" + Environment.NewLine + " [Link] " + Environment.NewLine + " public C D;" + Environment.NewLine + " [Link] E F;" + Environment.NewLine + " [Description(\"Turn ferliser applications on? \")]" + Environment.NewLine + " public yesnoType AllowFertiliser { get; set; }" + Environment.NewLine + " }" + Environment.NewLine + "}" + Environment.NewLine; var manager = new ManagerConverter(rootNode); manager.AddDeclaration("NutrientPool", "Humic", new string[] { "[Link]" }); // Ensure the link has been added below the using statement. Assert.AreEqual(manager.ToString(), "using System;" + Environment.NewLine + "namespace Models" + Environment.NewLine + "{" + Environment.NewLine + " [Serializable]" + Environment.NewLine + " public class Script : Model" + Environment.NewLine + " {" + Environment.NewLine + " [Link] private A B;" + Environment.NewLine + " [Link]" + Environment.NewLine + " public C D;" + Environment.NewLine + " [Link] private E F;" + Environment.NewLine + " [Link]" + Environment.NewLine + " private NutrientPool Humic;" + Environment.NewLine + " [Description(\"Turn ferliser applications on? \")]" + Environment.NewLine + " public yesnoType AllowFertiliser { get; set; }" + Environment.NewLine + " }" + Environment.NewLine + "}" + Environment.NewLine); }