public void TestAddTemplate() { CommandsTemplates.Instance.AddTemplate("FirstCommand", "DoSomething", "FirstCommand /ok", false); CommandsTemplates.Instance.AddTemplate("FirstCommand", "DoAnotherThing", "FirstCommand /haha", false); CommandsTemplates.Instance.AddTemplate("SecondCommand", "DoSomething", "SecondCommand /ok", false); var templatesNames = CommandsTemplates.Instance.GetTemplatesNames("FirstCommand"); Assert.AreEqual(2, templatesNames.Count()); CommandsTemplatesFile.Save(CommandsTemplates.Instance); CommandsTemplates.Instance.DeleteTemplate("FirstCommand", "DoAnotherThing"); templatesNames = CommandsTemplates.Instance.GetTemplatesNames("FirstCommand"); Assert.AreEqual(1, templatesNames.Count()); var ct = new PrivateType(typeof(CommandsTemplatesFile)); var dic = ct.InvokeStatic("Load") as CommandsTemplatesDictionary;//Singleton of CommandsTemplates is broken here, but this is fine in unit testing. Assert.AreEqual(2, dic.Count); }
void MainForm_FormClosing(object sender, FormClosingEventArgs e) { Settings.Default.AssemblyNameOfCommand = defaultAssemblyName; Settings.Default.Save(); CommandsTemplatesFile.Save(CommandsTemplates.Instance); }