示例#1
0
        public void CanRemoveInvokerWithMultipleAdapters()
        {
            Command      command  = new Command();
            MockInvokerA invokerA = new MockInvokerA();
            MockInvokerB invokerB = new MockInvokerB();
            EventCommandAdapter <MockInvokerA> adapterA = new EventCommandAdapter <MockInvokerA>(invokerA, "Event");
            EventCommandAdapter <MockInvokerB> adapterB = new EventCommandAdapter <MockInvokerB>(invokerB, "Event");

            command.AddCommandAdapter(adapterA);
            command.AddCommandAdapter(adapterB);

            command.RemoveInvoker(invokerA, "Event");

            Assert.AreEqual(1, adapterB.Invokers.Count);
            Assert.AreEqual(0, adapterA.Invokers.Count);
        }
示例#2
0
        public void UnavailableCommandDisablesAndHidesItem()
        {
            Command command = new Command();
            ToolStripItemCommandAdapter adapter = new ToolStripItemCommandAdapter(item, "Click");

            command.AddCommandAdapter(adapter);

            command.Status = CommandStatus.Unavailable;

            Assert.IsFalse(item.Enabled);
            Assert.IsFalse(item.Visible);
        }
示例#3
0
        public void DisabledCommandDisablesButShowsItem()
        {
            Command command = new Command();
            ToolStripItemCommandAdapter adapter = new ToolStripItemCommandAdapter(item, "Click");

            command.AddCommandAdapter(adapter);

            command.Status = CommandStatus.Disabled;

            Assert.IsFalse(item.Enabled);
            Assert.IsTrue(item.Visible);
        }
示例#4
0
        public void UnavailableCommandDisablesAndHidesItem()
        {
            Command               command = new Command();
            MockInvoker           item    = new MockInvoker();
            ControlCommandAdapter adapter = new ControlCommandAdapter(item, "Event");

            command.AddCommandAdapter(adapter);

            command.Status = CommandStatus.Unavailable;

            Assert.IsFalse(item.Enabled);
            Assert.IsFalse(item.Visible);
        }
示例#5
0
        public void DisabledCommandDisablesButShowsItem()
        {
            Command               command = new Command();
            MockInvoker           item    = new MockInvoker();
            ControlCommandAdapter adapter = new ControlCommandAdapter(item, "Event");

            command.AddCommandAdapter(adapter);

            command.Status = CommandStatus.Disabled;

            Assert.IsFalse(item.Enabled);
            Assert.IsTrue(item.Visible);
        }
        public void InvokerIsWiredUp()
        {
            Command     command = new Command();
            MockInvoker invoker = new MockInvoker();
            EventCommandAdapter <MockInvoker> adapter = new EventCommandAdapter <MockInvoker>(invoker, "Event");

            command.AddCommandAdapter(adapter);
            MockListener listener = new MockListener();

            command.ExecuteAction += listener.CatchCommand;

            invoker.DoInvokeEvent();

            Assert.IsTrue(listener.CommandFired);
        }