public void TestConstructorInteger() { FPnl = new TPnlCollapsible(1337); Assert.AreEqual(1337, FPnl.ExpandedSize); FPnl.UserControlNamespace = HOSTEDUSERCONTROL; assertIsStable(FPnl); }
public void TestConstructorVisualStyle() { FPnl = new TPnlCollapsible(TVisualStylesEnum.vsDashboard); Assert.AreEqual(TVisualStylesEnum.vsDashboard, FPnl.VisualStyleEnum); assertIsStable(FPnl, false); }
public void TestConstructorBool() { FPnl = new TPnlCollapsible(false); Assert.AreEqual(false, FPnl.IsCollapsed); assertIsStable(FPnl, false); }
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); }
public void Setup() { new TLogging("TestCommonControls.log"); this.FPnl = new TPnlCollapsible(new object[] { THostedControlKind.hckUserControl, HOSTEDUSERCONTROL }); assertIsStable(FPnl); }
public void TestConstructorDirectionStyle() { FPnl = new TPnlCollapsible(TCollapseDirection.cdHorizontal, TVisualStylesEnum.vsShepherd); Assert.AreEqual(TVisualStylesEnum.vsShepherd, FPnl.VisualStyleEnum); Assert.AreEqual(TCollapseDirection.cdHorizontal, FPnl.CollapseDirection); assertIsStable(FPnl, false); }
public void TestConstructorString() { FPnl = new TPnlCollapsible("System.Console.Write"); Assert.AreEqual("System.Console", FPnl.UserControlNamespace); Assert.AreEqual("Write", FPnl.UserControlClass); Assert.AreEqual("System.Console.Write", FPnl.UserControlString); assertIsStable(FPnl); }
public void TestConstructorStringMalformed() { //again, we intentionally don't bother checking the usercontrol stuff very much at all. Below is expected behavior FPnl = new TPnlCollapsible("malformed UserControlString."); Assert.AreEqual("malformed UserControlString", FPnl.UserControlNamespace); Assert.AreEqual("", FPnl.UserControlClass); Assert.AreEqual("malformed UserControlString.", FPnl.UserControlString); assertIsStable(FPnl); }
public void TestConstructorVisualStyleBad() { // This should not change the style because vsShepherd isn't compatible with // default direction of vertical, and direction trumps style. FPnl = new TPnlCollapsible(TVisualStylesEnum.vsShepherd); Assert.AreNotEqual(TVisualStylesEnum.vsShepherd, FPnl.VisualStyleEnum); Assert.AreEqual(TPnlCollapsible.DEFAULT_STYLE[FPnl.CollapseDirection], FPnl.VisualStyleEnum); assertIsStable(FPnl, false); }
public void TestConstructorMultipleSameArguments() { // when given multiple arguments of same type, simply use the latest. FPnl = new TPnlCollapsible("first.control.given", "System.Console.Write"); Assert.AreEqual("System.Console", FPnl.UserControlNamespace); Assert.AreEqual("Write", FPnl.UserControlClass); Assert.AreEqual("System.Console.Write", FPnl.UserControlString); assertIsStable(FPnl); }
public void TestConstructorDirection() { FPnl = new TPnlCollapsible(TCollapseDirection.cdHorizontal); Assert.AreEqual(TPnlCollapsible.DEFAULT_STYLE[TCollapseDirection.cdHorizontal], FPnl.VisualStyleEnum); Assert.AreEqual(TCollapseDirection.cdHorizontal, FPnl.CollapseDirection); FPnl = new TPnlCollapsible(TCollapseDirection.cdVertical); Assert.AreEqual(TPnlCollapsible.DEFAULT_STYLE[TCollapseDirection.cdVertical], FPnl.VisualStyleEnum); Assert.AreEqual(TCollapseDirection.cdVertical, FPnl.CollapseDirection); assertIsStable(FPnl, false); }
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); }
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); }
public void TestHckDataMismatch() { FPnl = new TPnlCollapsible(THostedControlKind.hckUserControl); try { FPnl.AssertHckDataMatch(); } catch (Exception e) { Assert.AreEqual(typeof(EInsufficientDataSetForHostedControlKindException), e.GetType()); } }
public void TestStylesForDirection() { List <TVisualStylesEnum> AvailableStyles; AvailableStyles = TPnlCollapsible.StylesForDirection(TCollapseDirection.cdVertical); Assert.AreNotEqual(0, AvailableStyles.Count); AvailableStyles = TPnlCollapsible.StylesForDirection(TCollapseDirection.cdHorizontal); Assert.AreNotEqual(0, AvailableStyles.Count); AvailableStyles = TPnlCollapsible.StylesForDirection(TCollapseDirection.cdHorizontalRight); Assert.AreNotEqual(0, AvailableStyles.Count); }
public void TestToggleDirection() { FPnl = new TPnlCollapsible(THostedControlKind.hckUserControl, HOSTEDUSERCONTROL, TCollapseDirection.cdVertical); Assert.AreEqual(TCollapseDirection.cdVertical, FPnl.CollapseDirection); FPnl.ToggleDirection(); Assert.AreEqual(TCollapseDirection.cdHorizontal, FPnl.CollapseDirection); FPnl.ToggleDirection(); Assert.AreEqual(TCollapseDirection.cdVertical, FPnl.CollapseDirection); }
public void TestDirStyleMismatch() { FPnl = new TPnlCollapsible(THostedControlKind.hckUserControl, HOSTEDUSERCONTROL); try { FPnl.AssertDirStyleMatch(TCollapseDirection.cdHorizontal, TVisualStylesEnum.vsTaskPanel); } catch (Exception e) { Assert.AreEqual(typeof(EVisualStyleAndDirectionMismatchException), e.GetType()); } }
public void TestConstructorHck() { FPnl = new TPnlCollapsible(THostedControlKind.hckUserControl); Assert.AreEqual(THostedControlKind.hckUserControl, FPnl.HostedControlKind); try { assertIsStable(FPnl); } catch (Exception e) { Assert.AreEqual(typeof(EInsufficientDataSetForHostedControlKindException), e.GetType()); } }
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); }
public void TestConstructorDefault() { FPnl = new TPnlCollapsible(new object[] { }); assertIsStable(FPnl, false); FPnl = new TPnlCollapsible(new object[] { }); FPnl.UserControlNamespace = HOSTEDUSERCONTROL; assertIsStable(FPnl); // To ensure Unit Test code coverage only - nothing to assert here... FPnl.InitUserControl(); }
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); }
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()); } }
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 }); }
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); }
public void TestConstructorStringMalformedNoPeriod() { //again, we intentionally don't bother checking the usercontrol stuff very much at all. Below is expected behavior //This is more for documentation for now. FPnl = new TPnlCollapsible("malformed UserControlString with no period at end"); Assert.AreEqual("", FPnl.UserControlNamespace); Assert.AreEqual("", FPnl.UserControlClass); Assert.AreEqual(".", FPnl.UserControlString); try { assertIsStable(FPnl); } catch (Exception e) { Assert.AreEqual(typeof(EInsufficientDataSetForHostedControlKindException), e.GetType()); } }
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); }
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(); }
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); }