Ejemplo n.º 1
0
        public void TestGetHardCodedXmlNodes_ForDesignerOnly()
        {
            FPnl = new TPnlCollapsible(THostedControlKind.hckTaskList, TTestTaskList.GetTestXmlNode());

            // Need to resort to .NET Reflection as GetHardCodedXmlNodes_ForDesignerOnly() is a Private Method...
            MethodInfo InvokedPrivateMethod = FPnl.GetType().GetMethod("GetHardCodedXmlNodes_ForDesignerOnly",
                                                                       BindingFlags.NonPublic | BindingFlags.Instance);

            XmlNode Nodes = (XmlNode)InvokedPrivateMethod.Invoke(FPnl, new object[] { });

            Assert.IsNotNull(Nodes);
        }
Ejemplo n.º 2
0
        public void TestConstructorXmlNode()
        {
            XmlNode TestXmlNode = TTestTaskList.GetTestXmlNode();

            FPnl = new TPnlCollapsible(TestXmlNode, THostedControlKind.hckTaskList);
            Assert.AreEqual(TestXmlNode, FPnl.TaskListNode);
            assertIsStable2(FPnl);

            //Now we want to see if we can realise the task list without it throwing an exception.
            FPnl.Expand();
            assertIsStable2(FPnl);
        }
Ejemplo n.º 3
0
        public void TestLazyInitialisation()
        {
            // UserControl
            FPnl = new TPnlCollapsible(THostedControlKind.hckUserControl, HOSTEDUSERCONTROL);
            Assert.AreEqual(null, FPnl.UserControlInstance);    // Lazy initialisation!
            Assert.AreEqual(null, FPnl.TaskListInstance);
            Assert.AreEqual(null, FPnl.CollapsiblePanelHosterInstance);

            assertIsStable(FPnl);

            FPnl.Expand();
            Assert.AreNotEqual(null, FPnl.UserControlInstance); // Now initialised as Expand() got called
            Assert.AreEqual(null, FPnl.TaskListInstance);
            Assert.AreEqual(null, FPnl.CollapsiblePanelHosterInstance);

            assertIsStable(FPnl);
            FPnl.Collapse();
            assertIsStable(FPnl);

            // TaskList
            FPnl = new TPnlCollapsible(THostedControlKind.hckTaskList, TTestTaskList.GetTestXmlNode());
            Assert.AreEqual(null, FPnl.TaskListInstance);  // Lazy initialisation!

            assertIsStable2(FPnl);

            FPnl.Expand();
            Assert.AreNotEqual(null, FPnl.TaskListInstance);     // Now initialised as Expand() got called
            Assert.AreEqual(null, FPnl.UserControlInstance);
            Assert.AreEqual(null, FPnl.CollapsiblePanelHosterInstance);

            assertIsStable2(FPnl);
            FPnl.Collapse();
            assertIsStable2(FPnl);

            // CollapsiblePanelHoster
            FPnl = new TPnlCollapsible(THostedControlKind.hckCollapsiblePanelHoster, TTestTaskList.GetTestXmlNode());
            Assert.AreEqual(null, FPnl.CollapsiblePanelHosterInstance);  // Lazy initialisation!

            assertIsStable2(FPnl);

            FPnl.Expand();
            Assert.AreNotEqual(null, FPnl.CollapsiblePanelHosterInstance); // Now initialised as Expand() got called
            Assert.AreEqual(null, FPnl.UserControlInstance);
            Assert.AreEqual(null, FPnl.TaskListInstance);


            assertIsStable2(FPnl);
            FPnl.Collapse();
            assertIsStable2(FPnl);
        }
Ejemplo n.º 4
0
        public void TestSetter_CollapsiblePanelHosterInstance()
        {
            FPnl = new TPnlCollapsible(THostedControlKind.hckCollapsiblePanelHoster, TTestTaskList.GetTestXmlNode());
            FPnl.RealiseCollapsiblePanelHoster();

            TPnlCollapsibleHoster CpH1 = FPnl.CollapsiblePanelHosterInstance;

            TPnlCollapsibleHoster CpH2 = new TPnlCollapsibleHoster(TTestTaskList.GetTestXmlNode2(), TVisualStylesEnum.vsTaskPanel);

            FPnl.CollapsiblePanelHosterInstance = CpH2;

            Assert.AreNotEqual(CpH1, FPnl.CollapsiblePanelHosterInstance);

            assertIsStable2(FPnl);
        }
Ejemplo n.º 5
0
        public void TestSetter_TaskListInstance()
        {
            FPnl = new TPnlCollapsible(THostedControlKind.hckTaskList, TTestTaskList.GetTestXmlNode());
            FPnl.RealiseTaskListNow();

            TTaskList TLst1        = FPnl.TaskListInstance;
            int       ExpandedSize = FPnl.ExpandedSize;

            TTaskList TLst2 = new TTaskList(TTestTaskList.GetTestXmlNode2());

            FPnl.TaskListInstance = TLst2;

            Assert.AreNotEqual(TLst1, FPnl.TaskListInstance, "FPnl.TaskListInstance");

            Assert.AreNotEqual(ExpandedSize, FPnl.ExpandedSize, "ExpandedSize");

            assertIsStable2(FPnl);
        }
Ejemplo n.º 6
0
        public void TestLazyInitialisationCumulative()
        {
            // UserControl
            FPnl = new TPnlCollapsible(THostedControlKind.hckUserControl, HOSTEDUSERCONTROL);
            Assert.AreEqual(null, FPnl.UserControlInstance);    // Lazy initialisation!
            Assert.AreEqual(null, FPnl.TaskListInstance);
            Assert.AreEqual(null, FPnl.CollapsiblePanelHosterInstance);

            assertIsStable(FPnl);

            FPnl.Expand();
            Assert.AreNotEqual(null, FPnl.UserControlInstance); // Now initialised as Expand() got called
            Assert.AreEqual(null, FPnl.TaskListInstance);
            Assert.AreEqual(null, FPnl.CollapsiblePanelHosterInstance);

            FPnl.TaskListNode = TTestTaskList.GetTestXmlNode();
            Assert.AreEqual(null, FPnl.TaskListInstance);  // Lazy initialisation!

            // TaskList
            FPnl.HostedControlKind = THostedControlKind.hckTaskList;
            FPnl.Collapse();
            FPnl.Expand();
            Assert.AreNotEqual(null, FPnl.TaskListInstance);     // Now initialised as Expand() got called
            Assert.AreNotEqual(null, FPnl.UserControlInstance);  // This still exists from previous operation!
            Assert.AreEqual(null, FPnl.CollapsiblePanelHosterInstance);

            assertIsStable2(FPnl);

            // CollapsiblePanelHoster
            FPnl.HostedControlKind = THostedControlKind.hckCollapsiblePanelHoster;
            Assert.AreEqual(null, FPnl.CollapsiblePanelHosterInstance);    // Lazy initialisation!
            Assert.AreNotEqual(null, FPnl.TaskListInstance);               // This still exists from previous operation!
            Assert.AreNotEqual(null, FPnl.UserControlInstance);            // This still exists from previous operation!

            FPnl.Toggle();                                                 // same as FPnl.Collapse(); above
            FPnl.Toggle();                                                 // same as FPnl.Expand(); above
            Assert.AreNotEqual(null, FPnl.CollapsiblePanelHosterInstance); // Now initialised as Expand() got called (trough Toggle())
            Assert.AreNotEqual(null, FPnl.TaskListInstance);               // This still exists from previous operation!
            Assert.AreNotEqual(null, FPnl.UserControlInstance);            // This still exists from previous operation!

            assertIsStable2(FPnl);
        }
Ejemplo n.º 7
0
        public void TestExpandAdditionalCodeCoverage()
        {
            // UserControl
            FPnl = new TPnlCollapsible(THostedControlKind.hckUserControl, HOSTEDUSERCONTROL);
            FPnl.Expand();

            FPnl.HostedControlKind = THostedControlKind.hckTaskList;
            FPnl.TaskListNode      = TTestTaskList.GetTestXmlNode();

            FPnl.Expand();

            FPnl.HostedControlKind = THostedControlKind.hckCollapsiblePanelHoster;
            FPnl.Expand();

            FPnl.HostedControlKind = THostedControlKind.hckTaskList;
            FPnl.Expand();

            FPnl.HostedControlKind = THostedControlKind.hckUserControl;
            FPnl.Expand();
        }
Ejemplo n.º 8
0
        public void TestSetter_ActiveTaskItem()
        {
            XmlNode TestNode = TTestTaskList.GetTestXmlNode();

            FPnl = new TPnlCollapsible(THostedControlKind.hckTaskList, TestNode);
            FPnl.Expand();

            Assert.IsNull(FPnl.ActiveTaskItem);

            FPnl.ActiveTaskItem = TestNode.ChildNodes[1];
            Assert.AreEqual(FPnl.ActiveTaskItem, TestNode.ChildNodes[1]);

            FPnl.ActiveTaskItem = TestNode.ChildNodes[2];
            Assert.AreEqual(FPnl.ActiveTaskItem, TestNode.ChildNodes[2]);

            FPnl.ActiveTaskItem = null;

            Assert.IsNull(FPnl.ActiveTaskItem);

            FPnl.TaskListNode = null;

            Assert.IsNull(FPnl.ActiveTaskItem);
        }
Ejemplo n.º 9
0
        public void TestCollapsiblePanelHosterOtherTests()
        {
            // Ensure ENoTaskListNodeSpecifiedException is thrown if no TaskListNode got specified
            FPnl = new TPnlCollapsible(THostedControlKind.hckCollapsiblePanelHoster);

            try
            {
                FPnl.RealiseCollapsiblePanelHoster();
            }
            catch (Exception e)
            {
                Assert.AreEqual(typeof(ENoTaskListNodeSpecifiedException), e.GetType());
            }

            // To ensure Unit Test code coverage only - nothing to assert here...
            FPnl = new TPnlCollapsible(THostedControlKind.hckCollapsiblePanelHoster,
                                       TTestTaskList.GetTestXmlNode(), TCollapseDirection.cdHorizontalRight);
            FPnl.VisualStyleEnum = TVisualStylesEnum.vsHorizontalCollapse;

            FPnl.RealiseCollapsiblePanelHoster();

            // To ensure Unit Test code coverage only - nothing to assert here...
            FPnl.Expand();
        }
Ejemplo n.º 10
0
        public void TestSetter_VisualStyleEnum()
        {
            FPnl = new TPnlCollapsible(THostedControlKind.hckTaskList, TTestTaskList.GetTestXmlNode());

            Assert.AreEqual(TVisualStylesEnum.vsAccordionPanel, FPnl.VisualStyleEnum);

            FPnl.VisualStyleEnum = TVisualStylesEnum.vsTaskPanel;
            Assert.AreEqual(TVisualStylesEnum.vsTaskPanel, FPnl.VisualStyleEnum);

            FPnl.Collapse();           // To ensure Unit Test code coverage only - nothing to assert here...
            FPnl.Expand();             // To ensure Unit Test code coverage only - nothing to assert here...
            FPnl.RealiseTaskListNow(); // To ensure Unit Test code coverage only - nothing to assert here...

            FPnl.VisualStyleEnum = TVisualStylesEnum.vsAccordionPanel;
            Assert.AreEqual(TVisualStylesEnum.vsAccordionPanel, FPnl.VisualStyleEnum);

            FPnl.VisualStyleEnum = TVisualStylesEnum.vsDashboard;
            Assert.AreEqual(TVisualStylesEnum.vsDashboard, FPnl.VisualStyleEnum);
            FPnl.Expand();  // To ensure Unit Test code coverage only - nothing to assert here...

            // The following Tests should work with 'Assert.AreNotEqual' because the Visual Style we try to assign is only valid
            // for a different CollapseDirection: cdHorizontal or cdHorizontalRight
            FPnl.VisualStyleEnum = TVisualStylesEnum.vsHorizontalCollapse;
            Assert.AreNotEqual(TVisualStylesEnum.vsHorizontalCollapse, FPnl.VisualStyleEnum);

            FPnl.VisualStyleEnum = TVisualStylesEnum.vsShepherd;
            Assert.AreNotEqual(TVisualStylesEnum.vsShepherd, FPnl.VisualStyleEnum);


            // Specifiying 'TVisualStylesEnum.vsHorizontalCollapse' in the next statement, which is invalid and...
            FPnl = new TPnlCollapsible(THostedControlKind.hckUserControl, HOSTEDUSERCONTROL, TVisualStylesEnum.vsHorizontalCollapse);

            // ...gets automatically corrected to TVisualStylesEnum.vsDashboard by the Control!
            Assert.AreEqual(TVisualStylesEnum.vsDashboard, FPnl.VisualStyleEnum);

            FPnl.VisualStyleEnum = TVisualStylesEnum.vsAccordionPanel;
            Assert.AreEqual(TVisualStylesEnum.vsAccordionPanel, FPnl.VisualStyleEnum);

            FPnl.VisualStyleEnum = TVisualStylesEnum.vsTaskPanel;
            Assert.AreEqual(TVisualStylesEnum.vsTaskPanel, FPnl.VisualStyleEnum);

            FPnl.VisualStyleEnum = TVisualStylesEnum.vsDashboard;
            Assert.AreEqual(TVisualStylesEnum.vsDashboard, FPnl.VisualStyleEnum);

            // The following Tests should work with 'Assert.AreNotEqual' because the Visual Style we try to assign is only valid
            // for a different CollapseDirection: cdHorizontal or cdHorizontalRight
            FPnl.VisualStyleEnum = TVisualStylesEnum.vsHorizontalCollapse;
            Assert.AreNotEqual(TVisualStylesEnum.vsHorizontalCollapse, FPnl.VisualStyleEnum);

            FPnl.VisualStyleEnum = TVisualStylesEnum.vsShepherd;
            Assert.AreNotEqual(TVisualStylesEnum.vsShepherd, FPnl.VisualStyleEnum);


            FPnl = new TPnlCollapsible(THostedControlKind.hckCollapsiblePanelHoster, TTestTaskList.GetTestXmlNode());

            Assert.AreEqual(TVisualStylesEnum.vsAccordionPanel, FPnl.VisualStyleEnum);

            FPnl.VisualStyleEnum = TVisualStylesEnum.vsTaskPanel;
            Assert.AreEqual(TVisualStylesEnum.vsTaskPanel, FPnl.VisualStyleEnum);

            FPnl.VisualStyleEnum = TVisualStylesEnum.vsAccordionPanel;
            Assert.AreEqual(TVisualStylesEnum.vsAccordionPanel, FPnl.VisualStyleEnum);

            FPnl.VisualStyleEnum = TVisualStylesEnum.vsDashboard;
            Assert.AreEqual(TVisualStylesEnum.vsDashboard, FPnl.VisualStyleEnum);

            // The following Tests should work with 'Assert.AreNotEqual' because the Visual Style we try to assign is only valid
            // for a different CollapseDirection: cdHorizontal or cdHorizontalRight
            FPnl.VisualStyleEnum = TVisualStylesEnum.vsHorizontalCollapse;
            Assert.AreNotEqual(TVisualStylesEnum.vsHorizontalCollapse, FPnl.VisualStyleEnum);

            FPnl.VisualStyleEnum = TVisualStylesEnum.vsShepherd;
            Assert.AreNotEqual(TVisualStylesEnum.vsShepherd, FPnl.VisualStyleEnum);


            FPnl = new TPnlCollapsible(THostedControlKind.hckTaskList,
                                       TTestTaskList.GetTestXmlNode(), TVisualStylesEnum.vsShepherd, TCollapseDirection.cdHorizontal);

            Assert.AreEqual(TVisualStylesEnum.vsShepherd, FPnl.VisualStyleEnum);

            FPnl.VisualStyleEnum = TVisualStylesEnum.vsHorizontalCollapse;
            Assert.AreEqual(TVisualStylesEnum.vsHorizontalCollapse, FPnl.VisualStyleEnum);


            // To ensure Unit Test code coverage only - nothing to assert here...
            FPnl.RealiseTaskListNow();
            FPnl.VisualStyleEnum = TVisualStylesEnum.vsShepherd;


            // To ensure Unit Test code coverage only - nothing to assert here...
            FPnl = new TPnlCollapsible(THostedControlKind.hckTaskList,
                                       TTestTaskList.GetTestXmlNode(), TVisualStylesEnum.vsHorizontalCollapse, TCollapseDirection.cdHorizontal);
            FPnl.VisualStyleEnum = TVisualStylesEnum.vsHorizontalCollapse_InfoPanelWithGradient;
        }