/* we should allocate object on a separate stack */ private WeakReference RegisterDummyDelegate(string name) { Dummy dummy = new Dummy(); WeakReference reference = new WeakReference(new CommandAction<string[]>(dummy.Execute)); Lunar.RegisterCommand(name, dummy.Execute); return reference; }
public void TestRegisterMethodsCommandsFromTheSameObject() { CRegistery.Clear(); Dummy dummy = new Dummy(); CommandAction<string[]> del1 = dummy.Execute; CommandAction<string[]> del2 = dummy.Execute2; Lunar.RegisterCommand("del1", del1); Lunar.RegisterCommand("del2", del2); IList<CCommand> cmds = CRegistery.ListCommands("del"); Assert.AreEqual(2, cmds.Count); Assert.AreEqual(del1, (cmds[0] as CDelegateCommand).ActionDelegate); Assert.AreEqual(del2, (cmds[1] as CDelegateCommand).ActionDelegate); CRegistery.UnregisterAll(dummy); cmds = CRegistery.ListCommands("del"); Assert.AreEqual(0, cmds.Count); }