public void TestKeyBindingSetSaveXmlWithParent()
        {
            var cmd1   = new ActionCommand("Command1", "Test Command 1");
            var cmd2   = new ActionCommand("Command2", "Test Command 2");
            var cmd3   = new ActionCommand("Command3", "Test Command 3");
            var parent = new KeyBindingSet();

            parent.SetBinding(cmd1, "Ctrl+1");
            parent.SetBinding(cmd2, "Ctrl+2");
            var set1 = new KeyBindingSet(parent);

            set1.SetBinding(cmd3, "Ctrl+3");

            var sb = new StringBuilder();

            using (var str = new StringWriter(sb))
                using (var writer = new XmlTextWriter(str)
                {
                    Indentation = 0, Formatting = Formatting.None
                })
                    set1.Save(writer, "Scheme1");

            var xml = sb.ToString();

            // parent bindings should be ignored
            var expectedXml =
                "<scheme name=\"Scheme1\">" +
                "<binding command=\"Command3\" shortcut=\"Ctrl+3\" />" +
                "</scheme>";

            Assert.AreEqual(expectedXml, xml);

            // verify that parent overrides are stored, especially empty ones to disable bindings
            set1.SetBinding(cmd1, "Alt+1");
            set1.SetBinding(cmd2, string.Empty);

            sb.Clear();
            using (var str = new StringWriter(sb))
                using (var writer = new XmlTextWriter(str)
                {
                    Indentation = 0, Formatting = Formatting.None
                })
                    set1.Save(writer, "Scheme1");

            xml         = sb.ToString();
            expectedXml =
                "<scheme name=\"Scheme1\">" +
                "<binding command=\"Command3\" shortcut=\"Ctrl+3\" />" +
                "<binding command=\"Command1\" shortcut=\"Alt+1\" />" +
                "<binding command=\"Command2\" shortcut=\"\" />" +
                "</scheme>";

            Assert.AreEqual(expectedXml, xml);
        }
        public void TestKeyBindingSetSaveXml()
        {
            var cmd1 = new ActionCommand("Command1", "Test Command 1");
            var cmd2 = new ActionCommand("Command2", "Test Command 2");
            var cmd3 = new ActionCommand("Command3", "Test Command 3");
            var set1 = new KeyBindingSet();

            set1.SetBinding(cmd1, "Ctrl+1");
            set1.SetBinding(cmd2, "Ctrl+2");
            set1.SetBinding(cmd3, "Ctrl+3");

            var sb = new StringBuilder();

            using (var str = new StringWriter(sb))
                using (var writer = new XmlTextWriter(str)
                {
                    Indentation = 0, Formatting = Formatting.None
                })
                    set1.Save(writer, "Scheme1");

            var xml = sb.ToString();

            var expectedXml =
                "<scheme name=\"Scheme1\">" +
                "<binding command=\"Command1\" shortcut=\"Ctrl+1\" />" +
                "<binding command=\"Command2\" shortcut=\"Ctrl+2\" />" +
                "<binding command=\"Command3\" shortcut=\"Ctrl+3\" />" +
                "</scheme>";

            Assert.AreEqual(expectedXml, xml);

            // verify that empty bindings are not stored
            set1.SetBinding(cmd3, string.Empty);

            sb.Clear();
            using (var str = new StringWriter(sb))
                using (var writer = new XmlTextWriter(str)
                {
                    Indentation = 0, Formatting = Formatting.None
                })
                    set1.Save(writer, "Scheme1");

            xml         = sb.ToString();
            expectedXml =
                "<scheme name=\"Scheme1\">" +
                "<binding command=\"Command1\" shortcut=\"Ctrl+1\" />" +
                "<binding command=\"Command2\" shortcut=\"Ctrl+2\" />" +
                "</scheme>";

            Assert.AreEqual(expectedXml, xml);
        }