Example #1
0
        public void TestIsCollapsed()
        {
            FPnl = new TPnlCollapsible(THostedControlKind.hckUserControl, HOSTEDUSERCONTROL);

            Assert.IsTrue(FPnl.IsCollapsed);

            FPnl.Toggle();
            Assert.IsFalse(FPnl.IsCollapsed);
            FPnl.Toggle();
            Assert.IsTrue(FPnl.IsCollapsed);
            FPnl.Collapse();
            Assert.IsTrue(FPnl.IsCollapsed);
            FPnl.Expand();
            Assert.IsFalse(FPnl.IsCollapsed);

            FPnl = new TPnlCollapsible(THostedControlKind.hckUserControl, HOSTEDUSERCONTROL, false);
            Assert.IsFalse(FPnl.IsCollapsed);

            FPnl = new TPnlCollapsible(THostedControlKind.hckTaskList, true);
            Assert.IsTrue(FPnl.IsCollapsed);
            FPnl = new TPnlCollapsible(THostedControlKind.hckTaskList, false);
            Assert.IsFalse(FPnl.IsCollapsed);

            FPnl = new TPnlCollapsible(THostedControlKind.hckCollapsiblePanelHoster, true);
            Assert.IsTrue(FPnl.IsCollapsed);
            FPnl = new TPnlCollapsible(THostedControlKind.hckCollapsiblePanelHoster, false);
            Assert.IsFalse(FPnl.IsCollapsed);
        }
Example #2
0
        public void TestEvents()
        {
            // Not just test that Events are fired, but that the RIGHT Events are fired under
            // the RIGHT circumstances, and that no wrong Event is fired under wrong circumstances!
            // (Uses EventHandlerCapture Class for that as NUnit doesn't provide Asserts for
            // something nifty like that!)
            FPnl = new TPnlCollapsible(THostedControlKind.hckUserControl, HOSTEDUSERCONTROL);
            var EhcExpanded = new TNUnitEventHandlerCheck <System.EventArgs>();
            var EhcCollapsed = new TNUnitEventHandlerCheck <System.EventArgs>();

            FPnl.Expanded += EhcExpanded.Handler;
            FPnl.Collapsed += EhcCollapsed.Handler;

            // Assert that the Expanded Event is fired when the Control is Expanded (and that the Collapsed Event isn't)
            TNUnitEventAsserter.Assert(EhcExpanded, TNUnitEventAsserter.GotRaised <System.EventArgs>(), () => FPnl.Expand());
            TNUnitEventAsserter.Assert(EhcCollapsed, TNUnitEventAsserter.DidNotGetRaised <System.EventArgs>(), () => FPnl.Expand());

            // Assert that the Collapsed Event is fired when the Control is Expanded (and that the Expanded Event isn't)
            TNUnitEventAsserter.Assert(EhcCollapsed, TNUnitEventAsserter.GotRaised <System.EventArgs>(), () => FPnl.Collapse());
            TNUnitEventAsserter.Assert(EhcExpanded, TNUnitEventAsserter.DidNotGetRaised <System.EventArgs>(), () => FPnl.Collapse());

            FPnl.Expanded -= EhcExpanded.Handler;
            FPnl.Collapsed -= EhcCollapsed.Handler;

            // Assert that the Expanded/Collapsed Events are fired when the Control's Toggle Button is clicked
            // Need to resort to .NET Reflection as BtnToggleClick() is a Private Method...
            MethodInfo InvokedPrivateMethod = FPnl.GetType().GetMethod("BtnToggleClick",
                BindingFlags.NonPublic | BindingFlags.Instance);

            // It might look a bit weird to check Assert AreNotSame, but only this way we find out that the
            // .Invoke calls below do in fact do something!
            FPnl.Expanded += delegate(object sender, EventArgs e) {
                Assert.AreNotSame(FPnl, null);
            };
            FPnl.Expanded += delegate(object sender, EventArgs e) {
                Assert.AreSame(FPnl, sender);
            };
            FPnl.Collapsed += delegate(object sender, EventArgs e) {
                Assert.AreNotSame(FPnl, null);
            };
            FPnl.Collapsed += delegate(object sender, EventArgs e) {
                Assert.AreSame(FPnl, sender);
            };

            InvokedPrivateMethod.Invoke(FPnl, new object[] { FPnl, null });
            InvokedPrivateMethod.Invoke(FPnl, new object[] { FPnl, null });
        }
Example #3
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);
        }
Example #4
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();
        }
Example #5
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();
        }
Example #6
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);
        }
Example #7
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;
        }
Example #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);
        }
Example #9
0
        public void TestSetter_UserControlClass_UserControlNamespace_UserControlString()
        {
            // Changing of UserControl after realising a first UserControl specified through Constructor
            FPnl = new TPnlCollapsible(THostedControlKind.hckUserControl, HOSTEDUSERCONTROL);
            FPnl.RealiseUserControlNow();

            UserControl UC1 = FPnl.UserControlInstance;

            FPnl.UserControlClass = "TUC_Subscription";
            FPnl.UserControlNamespace = "Ict.Petra.Client.MPartner.Gui";
            FPnl.RealiseUserControlNow();

            Assert.AreNotEqual(UC1, FPnl.UserControlInstance);
            Assert.IsInstanceOf <Ict.Petra.Client.MPartner.Gui.TUC_Subscription>(FPnl.UserControlInstance);

            // Assigning of UserControl with UserControlClass and UserControlNamespace Properties
            FPnl = new TPnlCollapsible(new object[] { });
            FPnl.UserControlClass = "TUC_Subscription";
            FPnl.UserControlNamespace = "Ict.Petra.Client.MPartner.Gui";
            FPnl.RealiseUserControlNow();

            Assert.IsInstanceOf <Ict.Petra.Client.MPartner.Gui.TUC_Subscription>(FPnl.UserControlInstance);


            // Assigning of UserControl with UserControlString Property
            FPnl = new TPnlCollapsible(new object[] { });
            FPnl.UserControlString = "Ict.Petra.Client.MPartner.Gui.TUC_Subscription";

            // Calling Expand() has the side effect of instantiating the UserControl
            FPnl.Expand();

            UserControl UC2 = FPnl.UserControlInstance;
            Assert.IsInstanceOf <Ict.Petra.Client.MPartner.Gui.TUC_Subscription>(UC2);

            // Assures that a further call only makes a previously instantiated UserControl visible again
            FPnl.Expand();
            Assert.AreEqual(UC2, FPnl.UserControlInstance);
        }
Example #10
0
        public void TestConstructorUserControlWithInvalidClass()
        {
            FPnl = new TPnlCollapsible(THostedControlKind.hckUserControl, HOSTEDUSERCONTROL + "WRONG");

            assertIsStable(FPnl);

            //Now we want to check that we can't realise the task list without it throwing an exception.
            try
            {
                FPnl.Expand();
            }
            catch (Exception e)
            {
                Assert.AreEqual(typeof(EUserControlCantInstantiateClassException), e.GetType());
            }
        }
Example #11
0
        public void TestConstructorUserControlWithoutUserControlString()
        {
            FPnl = new TPnlCollapsible(THostedControlKind.hckUserControl);

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

            //Now we want to check that we can't realise the task list without it throwing an exception.
            try
            {
                FPnl.Expand();
            }
            catch (Exception e)
            {
                Assert.AreEqual(typeof(EUserControlInvalidNamespaceSpecifiedException), e.GetType());
            }
        }
Example #12
0
        public void TestConstructorTaskListWithoutXmlNode()
        {
            FPnl = new TPnlCollapsible(THostedControlKind.hckTaskList);

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

            //Now we want to check that we can't realise the task list without it throwing an exception.
            try
            {
                FPnl.Expand();
            }
            catch (Exception e)
            {
                Assert.AreEqual(typeof(ENoTaskListNodeSpecifiedException), e.GetType());
            }
        }
Example #13
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);
        }