Пример #1
0
        public void ShowFiresActivatedEventWithSPAsParameter()
        {
            ControlSmartPart  smartPartA     = new ControlSmartPart();
            ZoneSmartPartInfo smartPartInfoA = new ZoneSmartPartInfo();

            smartPartInfoA.ZoneName = "Zone";

            Control zone = new Control();

            workspace.Controls.Add(zone);
            workspace.SetZoneName(zone, "Zone");

            bool activatedCalled = false;

            workspace.SmartPartActivated += delegate(object sender, WorkspaceEventArgs e)
            {
                activatedCalled = true;
                Assert.AreSame(e.SmartPart, smartPartA);
            };

            workspace.Show(smartPartA, smartPartInfoA);
            Assert.IsTrue(smartPartA.Visible);

            Assert.IsTrue(activatedCalled);
        }
Пример #2
0
        public void SetUp()
        {
            workItem  = new TestableRootWorkItem();
            workspace = new ZoneWorkspace();
            control   = new Control();

            workItem.Services.Add(typeof(IWorkItemActivationService), new SimpleWorkItemActivationService());
            workItem.Workspaces.Add(workspace);
            ISmartPartInfo info = new ZoneSmartPartInfo("Main");

            workItem.RegisterSmartPartInfo(control, info);
        }
Пример #3
0
        public void ZoneDocksControlCorrectly()
        {
            Control zone = new Control();

            workspace.Controls.Add(zone);
            workspace.SetZoneName(zone, "Main");
            ZoneSmartPartInfo info = new ZoneSmartPartInfo();

            info.Dock = DockStyle.Fill;
            workspace.Show(control, info);

            Assert.AreEqual(DockStyle.Fill, workspace.Zones["Main"].Controls[0].Dock);
        }
Пример #4
0
        public void WorkspaceGetsRegisteredSPI()
        {
            Control zone = new Control();

            workspace.Controls.Add(zone);
            workspace.SetZoneName(zone, "Main");
            ZoneSmartPartInfo info = new ZoneSmartPartInfo();

            info.Dock = DockStyle.Fill;

            workItem.RegisterSmartPartInfo(control, info);
            workspace.Show(control, info);

            Assert.AreEqual(DockStyle.Fill, workspace.Zones["Main"].Controls[0].Dock);
        }
Пример #5
0
        public void CanShowInDefaultZoneWithInfoNoZoneName()
        {
            Control zone = new Control();

            workspace.Controls.Add(zone);
            workspace.SetZoneName(zone, "TestZone");
            workspace.SetIsDefaultZone(zone, true);

            Control           smartPartA = new Control();
            ZoneSmartPartInfo info       = new ZoneSmartPartInfo();

            info.Dock  = DockStyle.Fill;
            info.Title = "Test";
            workspace.Show(smartPartA, info);

            Assert.IsTrue(workspace.GetIsDefaultZone(zone));
            Assert.AreSame(smartPartA, workspace.Zones["TestZone"].Controls[0]);
        }
Пример #6
0
        public void FiresOneEventOnlyIfSmartPartIsShownMultipleTimes()
        {
            // Show First SmartPart
            ControlSmartPart  smartPartA     = new ControlSmartPart();
            ZoneSmartPartInfo smartPartInfoA = new ZoneSmartPartInfo();

            smartPartInfoA.ZoneName = "Zone";

            Control zone = new Control();

            workspace.Controls.Add(zone);
            workspace.SetZoneName(zone, "Zone");

            workspace.Show(smartPartA, smartPartInfoA);
            Assert.IsTrue(smartPartA.Visible);

            // Show Second SmartPart
            ControlSmartPart  smartPartB     = new ControlSmartPart();
            ZoneSmartPartInfo smartPartInfoB = new ZoneSmartPartInfo();

            smartPartInfoB.ZoneName = "Zone1";

            Control zone1 = new Control();

            workspace.Controls.Add(zone1);
            workspace.SetZoneName(zone1, "Zone1");

            workspace.Show(smartPartB, smartPartInfoB);
            Assert.IsTrue(smartPartB.Visible);

            // Show first SmartPart again
            int activatedCalled = 0;

            workspace.SmartPartActivated += delegate(object sender, WorkspaceEventArgs e)
            {
                activatedCalled++;
                Assert.AreSame(e.SmartPart, smartPartA);
            };

            workspace.Show(smartPartA, smartPartInfoA);

            Assert.AreEqual(1, activatedCalled);
        }
Пример #7
0
        public void ShowGetsSmartPartInfoRegisteredWithWorkItem1()
        {
            ControlSmartPart smartPartA = new ControlSmartPart();

            ZoneSmartPartInfo smartPartInfoA = new ZoneSmartPartInfo();

            smartPartInfoA.ZoneName = "ZoneA";
            smartPartInfoA.Dock     = DockStyle.Left;

            workItem.RegisterSmartPartInfo(smartPartA, smartPartInfoA);

            Control zoneA = new Control();

            workspace.Controls.Add(zoneA);
            workspace.SetZoneName(zoneA, "ZoneA");

            workspace.Show(smartPartA);

            Assert.IsTrue(workspace.Zones["ZoneA"].Controls.Contains(smartPartA));
            Assert.AreEqual(DockStyle.Left, smartPartA.Dock);
        }
Пример #8
0
        public void RemovingZoneFromWorkspaceRemovesContainedSmartPart()
        {
            Control zone = new Control();

            workspace.Controls.Add(zone);

            workspace.SetZoneName(zone, "TestZone3");

            ControlSmartPart  smartPartA = new ControlSmartPart();
            ZoneSmartPartInfo spInfoA    = new ZoneSmartPartInfo();

            spInfoA.ZoneName = "TestZone3";

            workspace.Show(smartPartA, spInfoA);
            zone.Focus();
            Form f = new Form();

            f.Controls.Add(zone);

            //Fails
            Assert.IsFalse(workspace.SmartParts.Contains(smartPartA));
        }