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); }
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); }
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); }
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); }
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); }