Beispiel #1
0
        public void AdapterCreatedByCommandIsRemovedWhenLastInvokerRemoved()
        {
            WorkItem wi = new TestableRootWorkItem();
            ICommandAdapterMapService svc = wi.Services.Get <ICommandAdapterMapService>();

            svc.Register(typeof(Control), typeof(MockControlAdapter));

            Command cmd = wi.Commands.AddNew <Command>();

            Control invoker = new Control();

            cmd.AddInvoker(invoker, "GotFocus");

            MockControlAdapter adapter = (MockControlAdapter)cmd.Adapters[0];

            adapter.AddInvoker(invoker, "Click");

            cmd.RemoveInvoker(invoker, "GotFocus");

            Assert.IsFalse(adapter.IsDisposed);

            cmd.RemoveInvoker(invoker, "Click");

            Assert.IsTrue(adapter.IsDisposed);

            adapter.IsDisposed = false;

            cmd.Dispose();
            // Should not be disposed again as it shouldn't be contained at all in the command anymore.
            Assert.IsFalse(adapter.IsDisposed);
        }
Beispiel #2
0
        public void UserAddedAdapterIsNotDisposedWithCommand()
        {
            Control            invoker = new Control();
            MockControlAdapter adapter = new MockControlAdapter(invoker, "GotFocus");

            command.AddCommandAdapter(adapter);

            command.Dispose();

            Assert.IsFalse(adapter.IsDisposed);
        }
Beispiel #3
0
        public void AdapterCratedByCommandIsDisposedWithCommand()
        {
            WorkItem wi = new TestableRootWorkItem();
            ICommandAdapterMapService svc = wi.Services.Get <ICommandAdapterMapService>();

            svc.Register(typeof(Control), typeof(MockControlAdapter));

            Command cmd = wi.Commands.AddNew <Command>();

            Control invoker = new Control();

            cmd.AddInvoker(invoker, "GotFocus");

            MockControlAdapter adapter = (MockControlAdapter)cmd.Adapters[0];

            cmd.Dispose();
            Assert.IsTrue(adapter.IsDisposed);
        }