Esempio n. 1
0
        public void Test_Set_SelectedBusinessObject_BOColNull_ShouldRaiseError()
        {
            //---------------Set up test pack-------------------
            ITabControl            tabControl      = CreateTabControl();
            IControlFactory        controlFactory  = GetControlFactory();
            BOColTabControlManager selectorManager = new BOColTabControlManager(tabControl, controlFactory);
            MyBO selectedBO = new MyBO();

            selectorManager.BusinessObjectControl    = this.GetBusinessObjectControl();
            selectorManager.BusinessObjectCollection = null;
            //---------------Assert Precondition----------------
            Assert.IsNull(selectorManager.BusinessObjectCollection);
            Assert.IsNotNull(selectorManager.BusinessObjectControl);
            //---------------Execute Test ----------------------
            try
            {
                selectorManager.CurrentBusinessObject = selectedBO;
                Assert.Fail("expected Err");
            }
            //---------------Test Result -----------------------
            catch (HabaneroDeveloperException ex)
            {
                const string expectedMessage = "You cannot set the 'CurrentBusinessObject' for BOColTabControlManager since the BusinessObjectCollection has not been set";
                StringAssert.Contains(expectedMessage, ex.Message);
            }
        }
Esempio n. 2
0
        public void Test_WhenChangeTabIndex_ShouldNotRecreateTheBOControl()
        {
            //---------------Set up test pack-------------------
            BusinessObjectControlCreatorDelegate creator;
            BOColTabControlManager selectorManager = GetselectorManager(out creator);

            MyBO firstBO  = new MyBO();
            MyBO secondBO = new MyBO();
            BusinessObjectCollection <MyBO> myBoCol = new BusinessObjectCollection <MyBO> {
                firstBO, secondBO
            };

            selectorManager.BusinessObjectCollection = myBoCol;
            ITabPage firstTabPage = selectorManager.TabControl.TabPages[0];
            IBusinessObjectControl firstBOControl = (IBusinessObjectControl)firstTabPage.Controls[0];
            ITabPage secondTabPage = selectorManager.TabControl.TabPages[1];
            IBusinessObjectControl secondBOControl = (IBusinessObjectControl)secondTabPage.Controls[0];

            //---------------Assert Precondition----------------
            Assert.AreSame(secondBO, secondBOControl.BusinessObject);
            Assert.AreSame(firstBOControl, selectorManager.BusinessObjectControl);
            Assert.AreEqual(2, selectorManager.TabControl.TabPages.Count);
            Assert.AreEqual(0, selectorManager.TabControl.SelectedIndex);
            //---------------Execute Test ----------------------
            selectorManager.CurrentBusinessObject = secondBO;
            //---------------Test Result -----------------------
            Assert.AreEqual(1, selectorManager.TabControl.SelectedIndex);
            Assert.AreSame(secondBOControl, secondTabPage.Controls[0]);
            Assert.AreSame(secondBOControl, selectorManager.BusinessObjectControl);
        }
Esempio n. 3
0
        public void Test_WhenUsingCreator_WhenSetBOCol_ShouldCreateTabPageWithControlFromCreator()
        {
            //---------------Set up test pack-------------------
            BusinessObjectControlCreatorDelegate creator;
            BOColTabControlManager selectorManager = GetselectorManager(out creator);
            MyBO expectedBO = new MyBO();
            BusinessObjectCollection <MyBO> myBoCol = new BusinessObjectCollection <MyBO>
            {
                expectedBO
            };

            //---------------Assert Precondition----------------
            Assert.IsNotNull(selectorManager.BusinessObjectControlCreator);
            Assert.AreEqual(creator, selectorManager.BusinessObjectControlCreator);
            Assert.AreEqual(0, selectorManager.TabControl.TabPages.Count);
            //---------------Execute Test ----------------------
            selectorManager.BusinessObjectCollection = myBoCol;
            //---------------Test Result -----------------------
            Assert.AreEqual(1, selectorManager.TabControl.TabPages.Count);
            ITabPage page = selectorManager.TabControl.TabPages[0];

            Assert.AreEqual(1, page.Controls.Count);
            IControlHabanero boControl = page.Controls[0];

            Assert.IsInstanceOf(TypeOfBusinessObjectControl(), boControl);
            IBusinessObjectControl businessObjectControl = (IBusinessObjectControl)boControl;

            Assert.AreSame(expectedBO, businessObjectControl.BusinessObject);
            Assert.AreSame(boControl, selectorManager.BusinessObjectControl);
        }
Esempio n. 4
0
        /// <summary>
        /// Constructor to initialise a new tab control
        /// </summary>
        public BOColTabControlWin(IControlFactory controlFactory)
        {
            if (controlFactory == null)
            {
                throw new ArgumentNullException("controlFactory");
            }
            _controlFactory = controlFactory;
            BorderLayoutManager layoutManager = _controlFactory.CreateBorderLayoutManager(this);

            _tabControl = _controlFactory.CreateTabControl();
            layoutManager.AddControl(_tabControl, BorderLayoutManager.Position.Centre);
            _boColTabControlManager = new BOColTabControlManager(_tabControl, _controlFactory);
            _boColTabControlManager.BusinessObjectSelected += delegate { FireBusinessObjectSelected(); };
            _boColTabControlManager.TabPageAdded           += (sender, e) => FireTabPageAdded(e.TabPage, e.BOControl);
            _boColTabControlManager.TabPageRemoved         += (sender, e) => FireTabPageRemoved(e.TabPage, e.BOControl);

            this.OnAsyncOperationStarted += (sender, e) =>
            {
                this.UseWaitCursor = true;
                this.Cursor        = Cursors.WaitCursor;
                this.Enabled       = false;
            };

            this.OnAsyncOperationComplete += (sender, e) =>
            {
                this.UseWaitCursor = false;
                this.Cursor        = Cursors.Default;
                this.Enabled       = true;
            };
        }
Esempio n. 5
0
        public void Test_Set_Collection_WhenBOControlNotSet_ShouldRaiseError()
        {
            //---------------Set up test pack-------------------
            ITabControl                     tabControl      = CreateTabControl();
            IControlFactory                 controlFactory  = GetControlFactory();
            BOColTabControlManager          selectorManager = new BOColTabControlManager(tabControl, controlFactory);
            BusinessObjectCollection <MyBO> myBoCol         = new BusinessObjectCollection <MyBO> {
                new MyBO(), new MyBO(), new MyBO()
            };

            //---------------Assert Precondition----------------
            Assert.IsNull(selectorManager.BusinessObjectCollection);
            Assert.IsNull(selectorManager.BusinessObjectControl);
            //---------------Execute Test ----------------------
            try
            {
                selectorManager.BusinessObjectCollection = myBoCol;
                Assert.Fail("expected Err");
            }
            //---------------Test Result -----------------------
            catch (HabaneroDeveloperException ex)
            {
                const string expectedMessage = "You cannot set the 'BusinessObjectCollection' for BOColTabControlManager since the BusinessObjectControl has not been set";
                StringAssert.Contains(expectedMessage, ex.Message);
            }
        }
Esempio n. 6
0
        public void Test_Set_CurrentBusinessObject_WhenUsingABusinessObjectControl_ShouldOnlySetBOOnce()
        {
            //---------------Set up test pack-------------------
            ITabControl            tabControl      = CreateTabControl();
            IControlFactory        controlFactory  = GetControlFactory();
            BOColTabControlManager selectorManager = new BOColTabControlManager(tabControl, controlFactory);
            MyBO firstBo;
            BusinessObjectCollection <MyBO> myBoCol = GetMyBoCol_3Items(out firstBo);
            var list = new List <IBusinessObject>();
            var businessObjectControl = GetBusinessObjectControlSpy(list.Add);

            selectorManager.BusinessObjectControl    = businessObjectControl;
            selectorManager.BusinessObjectCollection = myBoCol;
            list.Clear();
            //---------------Assert Precondition----------------
            Assert.IsTrue(selectorManager.AutoSelectFirstItem);
            Assert.AreEqual(0, list.Count);
            //---------------Execute Test ----------------------
            var newSelectedBo = myBoCol[1];

            selectorManager.CurrentBusinessObject = newSelectedBo;
            //---------------Test Result -----------------------
            Assert.AreEqual(1, list.Count);
            Assert.AreEqual(newSelectedBo, list[0]);
        }
Esempio n. 7
0
        protected virtual BOColTabControlManager CreateBOTabControlManager(ITabControl tabControl)
        {
            IControlFactory        controlFactory  = GetControlFactory();
            BOColTabControlManager selectorManager = new BOColTabControlManager(tabControl, controlFactory);

            selectorManager.BusinessObjectControl = GetBusinessObjectControl();
            return(selectorManager);
        }
Esempio n. 8
0
        protected virtual BOColTabControlManager GetselectorManager(out BusinessObjectControlCreatorDelegate creator)
        {
            IControlFactory        controlFactory  = GetControlFactory();
            ITabControl            tabControl      = controlFactory.CreateTabControl();
            BOColTabControlManager selectorManager = new BOColTabControlManager(tabControl, controlFactory);

            creator = BusinessObjectControlCreator;
            selectorManager.BusinessObjectControlCreator = creator;
            return(selectorManager);
        }
Esempio n. 9
0
        public void TestConstructor()
        {
            //---------------Set up test pack-------------------
            ITabControl     tabControl     = CreateTabControl();
            IControlFactory controlFactory = GetControlFactory();
            //---------------Execute Test ----------------------
            BOColTabControlManager selectorManager = new BOColTabControlManager(tabControl, controlFactory);

            //---------------Test Result -----------------------
            Assert.IsNotNull(selectorManager);
            Assert.AreSame(tabControl, selectorManager.TabControl);
//            Assert.AreSame(controlFactory, selectorManager.ControlFactory);
        }
Esempio n. 10
0
        public void TestConstructor()
        {
            //---------------Set up test pack-------------------
            ITabControl tabControl = GetControlFactory().CreateTabControl();
            //---------------Execute Test ----------------------
            BOColTabControlManager colTabCtlMapper = new BOColTabControlManager(tabControl, GetControlFactory());

            //---------------Test Result -----------------------
            Assert.IsNotNull(colTabCtlMapper);
            Assert.IsNotNull(colTabCtlMapper.PageBoTable);
            Assert.IsNotNull(colTabCtlMapper.BoPageTable);
            Assert.AreSame(tabControl, colTabCtlMapper.TabControl);
            //---------------Tear down -------------------------
        }
Esempio n. 11
0
        public void TestSetBusinessObjectControl()
        {
            //---------------Set up test pack-------------------
            ITabControl            tabControl      = GetControlFactory().CreateTabControl();
            BOColTabControlManager colTabCtlMapper = new BOColTabControlManager(tabControl, GetControlFactory());
            //---------------Execute Test ----------------------
            IBusinessObjectControl busControl = CreateBusinessObjectControl();

            colTabCtlMapper.BusinessObjectControl = busControl;

            //---------------Test Result -----------------------
            Assert.AreSame(busControl, colTabCtlMapper.BusinessObjectControl);
            //---------------Tear down -------------------------
        }
Esempio n. 12
0
        public void Test_Set_Collection_WithNull()
        {
            //---------------Set up test pack-------------------

            ITabControl            tabControl      = CreateTabControl();
            BOColTabControlManager selectorManager = new BOColTabControlManager(tabControl, GetControlFactory());

            selectorManager.BusinessObjectControl = GetBusinessObjectControl();
            //---------------Verify test pack-------------------
            //---------------Execute Test ----------------------
            selectorManager.BusinessObjectCollection = null;
            //---------------Verify Result -----------------------
            Assert.IsNull(selectorManager.BusinessObjectCollection);
            Assert.AreSame(tabControl, selectorManager.TabControl);
        }
Esempio n. 13
0
        public void Test_WhenUsingCreator_SetUpBOTabColManagerWithDelegateForCreating_aBOControl()
        {
            //---------------Set up test pack-------------------
            ITabControl            tabControl            = CreateTabControl();
            IControlFactory        controlFactory        = GetControlFactory();
            BOColTabControlManager selectorManager       = new BOColTabControlManager(tabControl, controlFactory);
            BusinessObjectControlCreatorDelegate creator = BusinessObjectControlCreator;

            //---------------Assert Precondition----------------
            Assert.IsNull(selectorManager.BusinessObjectControlCreator);
            //---------------Execute Test ----------------------
            selectorManager.BusinessObjectControlCreator = creator;
            //---------------Test Result -----------------------
            Assert.IsNotNull(selectorManager.BusinessObjectControlCreator);
            Assert.AreEqual(creator, selectorManager.BusinessObjectControlCreator);
        }
Esempio n. 14
0
        /// <summary>
        /// Constructor to initialise a new tab control
        /// </summary>
        public BOColTabControlVWG(IControlFactory controlFactory)
        {
            if (controlFactory == null)
            {
                throw new ArgumentNullException("controlFactory");
            }
            _controlFactory = controlFactory;
            BorderLayoutManager manager = _controlFactory.CreateBorderLayoutManager(this);

            _tabControl = _controlFactory.CreateTabControl();
            manager.AddControl(_tabControl, BorderLayoutManager.Position.Centre);
            _boColTabControlManager = new BOColTabControlManager(_tabControl, _controlFactory);
            _boColTabControlManager.BusinessObjectSelected += delegate { FireBusinessObjectSelected(); };
            _boColTabControlManager.TabPageAdded           += (sender, e) => FireTabPageAdded(e.TabPage, e.BOControl);
            _boColTabControlManager.TabPageRemoved         += (sender, e) => FireTabPageRemoved(e.TabPage, e.BOControl);
        }
Esempio n. 15
0
        public void TestBusinessObejctRemovedFromCollection()
        {
            ITabControl            tabControl      = CreateTabControl();
            BOColTabControlManager selectorManager = CreateBOTabControlManager(tabControl);
            MyBO removedBo = new MyBO();
            BusinessObjectCollection <MyBO> myBoCol = new BusinessObjectCollection <MyBO>
            {
                new MyBO(), removedBo, new MyBO()
            };

            selectorManager.BusinessObjectCollection = myBoCol;
            //---------------Execute Test ----------------------
            selectorManager.BusinessObjectCollection.Remove(removedBo);
            //---------------Test Result -----------------------
            Assert.AreEqual(2, selectorManager.TabControl.TabPages.Count);
        }
Esempio n. 16
0
        public void TestCreateTestTabControlCollectionController()
        {
            //---------------Set up test pack-------------------
            BusinessObjectCollection <MyBO> myBOs = new BusinessObjectCollection <MyBO> {
                { new MyBO(), new MyBO() }
            };
            ITabControl            tabControl      = CreateTabControl();
            BOColTabControlManager selectorManager = new BOColTabControlManager(tabControl, GetControlFactory());

            selectorManager.BusinessObjectControl = GetBusinessObjectControl();
            //---------------Verify test pack-------------------
            //---------------Execute Test ----------------------
            selectorManager.BusinessObjectCollection = myBOs;
            //---------------Verify Result -----------------------
            Assert.AreEqual(myBOs, selectorManager.BusinessObjectCollection);
            Assert.AreSame(tabControl, selectorManager.TabControl);
            //---------------Tear Down -------------------------
        }
Esempio n. 17
0
        public void Test_Set_Collection_ShouldPopulateTabs()
        {
            //---------------Set up test pack-------------------
            ITabControl                     tabControl      = CreateTabControl();
            IControlFactory                 controlFactory  = GetControlFactory();
            BOColTabControlManager          selectorManager = new BOColTabControlManager(tabControl, controlFactory);
            BusinessObjectCollection <MyBO> myBoCol         = new BusinessObjectCollection <MyBO>
            {
                new MyBO(), new MyBO(), new MyBO()
            };

            selectorManager.BusinessObjectControl = GetBusinessObjectControl();
            //---------------Execute Test ----------------------
            selectorManager.BusinessObjectCollection = myBoCol;
            //---------------Test Result -----------------------
            Assert.AreEqual(3, selectorManager.BusinessObjectCollection.Count);
            Assert.AreEqual(3, selectorManager.TabControl.TabPages.Count);
        }
Esempio n. 18
0
        public void Test_Set_Collection_WithAutoSelectFirstItemAsTrue_ShouldSelectFirstItem()
        {
            //---------------Set up test pack-------------------
            ITabControl            tabControl      = CreateTabControl();
            IControlFactory        controlFactory  = GetControlFactory();
            BOColTabControlManager selectorManager = new BOColTabControlManager(tabControl, controlFactory);
            MyBO firstBo;
            BusinessObjectCollection <MyBO> myBoCol = GetMyBoCol_3Items(out firstBo);

            selectorManager.BusinessObjectControl = GetBusinessObjectControl();
            selectorManager.AutoSelectFirstItem   = true;
            //---------------Assert Precondition----------------
            Assert.IsTrue(selectorManager.AutoSelectFirstItem);
            //---------------Execute Test ----------------------
            selectorManager.BusinessObjectCollection = myBoCol;
            //---------------Test Result -----------------------
            Assert.AreSame(firstBo, selectorManager.CurrentBusinessObject);
        }
Esempio n. 19
0
        public void Test_Selector_Clear_ClearsItems()
        {
            //---------------Set up test pack-------------------
            ITabControl            tabControl      = CreateTabControl();
            BOColTabControlManager selectorManager = CreateBOTabControlManager(tabControl);
            MyBO bo;
            BusinessObjectCollection <MyBO> col = GetMyBoCol_3Items(out bo);

            selectorManager.BusinessObjectCollection = col;
            //---------------Assert Preconditions --------------
            Assert.IsNotNull(selectorManager.CurrentBusinessObject);
            Assert.IsNotNull(selectorManager.BusinessObjectCollection);
            //---------------Execute Test ----------------------
            selectorManager.Clear();
            //---------------Test Result -----------------------
            Assert.IsNull(selectorManager.BusinessObjectCollection);
            Assert.IsNull(selectorManager.CurrentBusinessObject);
            Assert.AreEqual(0, selectorManager.NoOfItems);
        }
Esempio n. 20
0
        public void Test_WhenUsingCreator_WhenBusinessObejctRemovedToCollection_ShouldRemoveTab()
        {
            ITabControl            tabControl            = CreateTabControl();
            IControlFactory        controlFactory        = GetControlFactory();
            BOColTabControlManager selectorManager       = new BOColTabControlManager(tabControl, controlFactory);
            BusinessObjectControlCreatorDelegate creator = BusinessObjectControlCreator;

            selectorManager.BusinessObjectControlCreator = creator;

            MyBO removedBo = new MyBO();
            BusinessObjectCollection <MyBO> myBoCol = new BusinessObjectCollection <MyBO> {
                removedBo, new MyBO(), new MyBO()
            };

            selectorManager.BusinessObjectCollection = myBoCol;
            bool             pageRemovedEventFired = false;
            TabPageEventArgs ex = null;

            selectorManager.TabPageRemoved += (sender, e) =>
            {
                pageRemovedEventFired = true;
                ex = e;
            };
            ITabPage         tabPage = selectorManager.TabControl.TabPages[0];
            IControlHabanero boControlToBeRemoved = tabPage.Controls[0];

            //---------------Assert Precondition----------------
            Assert.AreEqual(3, selectorManager.TabControl.TabPages.Count);
            Assert.IsFalse(pageRemovedEventFired);
            //---------------Execute Test ----------------------
            selectorManager.BusinessObjectCollection.Remove(removedBo);
            //---------------Test Result -----------------------
            Assert.AreEqual(2, selectorManager.TabControl.TabPages.Count);

            Assert.AreEqual(removedBo.ToString(), tabPage.Text);
            Assert.AreEqual(removedBo.ToString(), tabPage.Name);
            Assert.AreEqual(1, tabPage.Controls.Count);

            Assert.IsTrue(pageRemovedEventFired);
            Assert.IsNotNull(ex);
            Assert.AreSame(tabPage, ex.TabPage);
            Assert.AreSame(boControlToBeRemoved, ex.BOControl);
        }
Esempio n. 21
0
        public void Test_Set_SelectedBusinessObject()
        {
            //---------------Set up test pack-------------------
            ITabControl            tabControl      = CreateTabControl();
            IControlFactory        controlFactory  = GetControlFactory();
            BOColTabControlManager selectorManager = new BOColTabControlManager(tabControl, controlFactory);
            MyBO selectedBO = new MyBO();
            BusinessObjectCollection <MyBO> myBoCol = new BusinessObjectCollection <MyBO>
            {
                new MyBO(), selectedBO, new MyBO()
            };

            selectorManager.BusinessObjectControl = GetBusinessObjectControl();
            //---------------Execute Test ----------------------
            selectorManager.BusinessObjectCollection = myBoCol;
            selectorManager.CurrentBusinessObject    = selectedBO;
            //---------------Test Result -----------------------
            Assert.AreEqual(selectedBO, selectorManager.CurrentBusinessObject);
        }
Esempio n. 22
0
        public void Test_BusinessObjectAddedToCollection()
        {
            ITabControl            tabControl      = CreateTabControl();
            BOColTabControlManager selectorManager = CreateBOTabControlManager(tabControl);
            MyBO addedBo = new MyBO();
            BusinessObjectCollection <MyBO> myBoCol = new BusinessObjectCollection <MyBO>
            {
                new MyBO(), new MyBO(), new MyBO()
            };

            selectorManager.BusinessObjectCollection = myBoCol;
            //---------------Assert Precondition----------------
            Assert.AreEqual(3, selectorManager.TabControl.TabPages.Count);
            //---------------Execute Test ----------------------
            selectorManager.BusinessObjectCollection.Add(addedBo);
            //---------------Test Result -----------------------
            Assert.AreEqual(4, selectorManager.TabControl.TabPages.Count);
            Assert.AreEqual(addedBo.ToString(), selectorManager.TabControl.TabPages[3].Text);
            Assert.AreEqual(addedBo.ToString(), selectorManager.TabControl.TabPages[3].Name);
        }
Esempio n. 23
0
        public void TestSetCollection()
        {
            //---------------Set up test pack-------------------

            MyBO.LoadDefaultClassDef();
            ITabControl            tabControl      = GetControlFactory().CreateTabControl();
            BOColTabControlManager colTabCtlMapper = new BOColTabControlManager(tabControl, GetControlFactory());
            IBusinessObjectControl busControl      = this.CreateBusinessObjectControl();

            colTabCtlMapper.BusinessObjectControl = busControl;
            //---------------Execute Test ----------------------
            BusinessObjectCollection <MyBO> myBoCol = new BusinessObjectCollection <MyBO>();

            myBoCol.Add(new MyBO());
            myBoCol.Add(new MyBO());
            myBoCol.Add(new MyBO());
            colTabCtlMapper.BusinessObjectCollection = myBoCol;
            //---------------Test Result -----------------------
            Assert.AreSame(myBoCol, colTabCtlMapper.BusinessObjectCollection);
            Assert.AreEqual(3, colTabCtlMapper.TabControl.TabPages.Count);
            //---------------Tear down -------------------------
        }
Esempio n. 24
0
        public virtual void Test_SelectedBusinessObject_Null_DoesNothing()
        {
            //---------------Set up test pack-------------------
            //The control is being swapped out
            // onto each tab i.e. all the tabs use the Same BusinessObjectControl
            // setting the selected Bo to null is therefore not a particularly
            // sensible action on a BOTabControl.t up test pack-------------------
            ITabControl            tabControl      = CreateTabControl();
            BOColTabControlManager selectorManager = CreateBOTabControlManager(tabControl);
            MyBO myBO = new MyBO();
            BusinessObjectCollection <MyBO> collection = new BusinessObjectCollection <MyBO> {
                myBO
            };

            selectorManager.BusinessObjectCollection = collection;
            selectorManager.CurrentBusinessObject    = null;
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            IBusinessObject selectedBusinessObject = selectorManager.CurrentBusinessObject;

            //---------------Test Result -----------------------
            Assert.IsNotNull(selectedBusinessObject);
        }
Esempio n. 25
0
 /// <summary>
 /// Returns the business object represented in the specified tab page
 /// </summary>
 /// <param name="tabPage">The tab page</param>
 /// <returns>Returns the business object, or null if not available
 /// </returns>
 public IBusinessObject GetBo(ITabPage tabPage)
 {
     return(BOColTabControlManager.GetBo(tabPage));
 }
Esempio n. 26
0
 /// <summary>
 /// Returns the TabPage object that is representing the given
 /// business object
 /// </summary>
 /// <param name="bo">The business object being represented</param>
 /// <returns>Returns the TabPage object, or null if not found</returns>
 public ITabPage GetTabPage(IBusinessObject bo)
 {
     return(BOColTabControlManager.GetTabPage(bo));
 }
Esempio n. 27
0
 /// <summary>
 /// Clears the business object collection and the rows in the data table
 /// </summary>
 public void Clear()
 {
     BOColTabControlManager.Clear();
 }