public void Test_CreateOKCancelPanel_ShouldLayoutCorrectly()
        {
            //---------------Set up test pack-------------------
            IOKCancelDialogFactory okCancelDialogFactory = CreateOKCancelDialogFactory();
            IPanel nestedControl = GetControlFactory().CreatePanel();

            nestedControl.Width = 200;

            //---------------Execute Test ----------------------
            IControlHabanero dialogControl = okCancelDialogFactory.CreateOKCancelPanel(nestedControl);

            //---------------Test Result -----------------------
            Assert.AreEqual(2, dialogControl.Controls.Count);
            Assert.IsInstanceOf(typeof(IPanel), dialogControl.Controls[0]);
            IPanel mainPanel = (IPanel)dialogControl.Controls[0];

            //Assert.AreEqual(DockStyle.Fill, mainPanel.Dock);
            Assert.AreSame(nestedControl, mainPanel.Controls[0]);
            Assert.AreEqual(DockStyle.Fill, mainPanel.Controls[0].Dock);
            Assert.IsInstanceOf(typeof(IButtonGroupControl), dialogControl.Controls[1]);
            IButtonGroupControl buttons = (IButtonGroupControl)dialogControl.Controls[1];

            Assert.AreEqual(DockStyle.Bottom, buttons.Dock);
            Assert.AreEqual(2, buttons.Controls.Count);
            Assert.IsNotNull(buttons["OK"]);
            Assert.IsNotNull(buttons["Cancel"]);
            //Assert.That(buttons["OK"].Right, Is.LessThan(buttons["Cancel"].Left));
        }
Esempio n. 2
0
        //this is Currently untestable, the layout has been tested in the CreateControlPanel method.
        /// <summary>
        /// Shows the form to the user
        /// </summary>
        public DialogResult ShowDialog()
        {
            IPanel panel = createControlPanel();
            IOKCancelDialogFactory okCancelDialogFactory = _controlFactory.CreateOKCancelDialogFactory();
            IFormHabanero          form = okCancelDialogFactory.CreateOKCancelForm(panel, "");

            return(form.ShowDialog());
        }
        internal IFormHabanero CreateOKCancelForm()
        {
            IPanel panel = CreateControlPanel();
            IOKCancelDialogFactory okCancelDialogFactory = _controlFactory.CreateOKCancelDialogFactory();
            IFormHabanero          form = okCancelDialogFactory.CreateOKCancelForm(panel, "Select");

            form.MinimumSize     = form.Size;
            form.FormBorderStyle = FormBorderStyle.FixedToolWindow;
            return(form);
        }
Esempio n. 4
0
        public void Test_CreateOKCancelForm_ShouldSetupOKButtonAsAcceptButton()
        {
            //---------------Set up test pack-------------------
            IOKCancelDialogFactory okCancelDialogFactory = CreateOKCancelDialogFactory();
            //---------------Execute Test ----------------------
            FormWin dialogForm = (FormWin)okCancelDialogFactory.CreateOKCancelForm(GetControlFactory().CreatePanel(), "");
            //---------------Test Result -----------------------
            IButtonGroupControl buttons = (IButtonGroupControl)dialogForm.Controls[0].Controls[1];

            Assert.AreSame(buttons["OK"], dialogForm.AcceptButton);
        }
        public void Test_CreateOKCancelForm_ShouldDockPanel()
        {
            //---------------Set up test pack-------------------
            IOKCancelDialogFactory okCancelDialogFactory = CreateOKCancelDialogFactory();
            //---------------Execute Test ----------------------
            IFormHabanero dialogForm = okCancelDialogFactory.CreateOKCancelForm(GetControlFactory().CreatePanel(), "");

            //---------------Test Result -----------------------
            Assert.AreEqual(1, dialogForm.Controls.Count);
            Assert.AreEqual(DockStyle.Fill, dialogForm.Controls[0].Dock);
        }
        public void Test_CreateOKCancelPanel_ShouldNestControl()
        {
            //---------------Set up test pack-------------------
            IOKCancelDialogFactory okCancelDialogFactory = CreateOKCancelDialogFactory();
            IControlHabanero       nestedControl         = GetControlFactory().CreatePanel();
            //---------------Execute Test ----------------------
            IControlHabanero dialogControl = okCancelDialogFactory.CreateOKCancelPanel(nestedControl);
            //---------------Test Result -----------------------
            IPanel contentPanel = (IPanel)dialogControl.Controls[0];

            Assert.AreEqual(1, contentPanel.Controls.Count);
            Assert.AreSame(nestedControl, contentPanel.Controls[0]);
            Assert.AreEqual(DockStyle.Fill, nestedControl.Dock);
        }
        public void Test_CreateOKCancelPanel_ShouldLayoutCorrectly_OKButtonLeftOfCancelButton()
        {
            //---------------Set up test pack-------------------
            IOKCancelDialogFactory okCancelDialogFactory = CreateOKCancelDialogFactory();
            IPanel nestedControl = GetControlFactory().CreatePanel();

            nestedControl.Width = 200;

            //---------------Execute Test ----------------------
            IControlHabanero dialogControl = okCancelDialogFactory.CreateOKCancelPanel(nestedControl);
            //---------------Test Result -----------------------
            IButtonGroupControl buttons = (IButtonGroupControl)dialogControl.Controls[1];

            Assert.That(buttons["OK"].Right, Is.LessThan(buttons["Cancel"].Left));
        }
        public void Test_CreateOKCancelForm_ShouldNotChangeControlSize()
        {
            //---------------Set up test pack-------------------
            IOKCancelDialogFactory okCancelDialogFactory = CreateOKCancelDialogFactory();
            IControlHabanero       nestedControl         = GetControlFactory().CreatePanel();
            int width  = TestUtil.GetRandomInt(100, 500);
            int height = TestUtil.GetRandomInt(100, 500);

            nestedControl.Size = new Size(width, height);
            //---------------Assert Precondition----------------
            Assert.AreEqual(width, nestedControl.Width);
            Assert.AreEqual(height, nestedControl.Height);
            //---------------Execute Test ----------------------
            IControlHabanero dialogControl = okCancelDialogFactory.CreateOKCancelForm(nestedControl, "MyTestForm");

            //---------------Test Result -----------------------
            Assert.AreEqual(width, nestedControl.Width, "Width should not have changed");
            Assert.GreaterOrEqual(nestedControl.Height, height, "Height should not have changed, but might have changed to be a bit bigger (due to how VWG works its fill docking)");
        }
        public void Test_CreateOKCancelPanel_ShouldNotChangeControlSize()
        {
            //---------------Set up test pack-------------------
            IOKCancelDialogFactory okCancelDialogFactory = CreateOKCancelDialogFactory();
            IControlHabanero       nestedControl         = GetControlFactory().CreatePanel();
            int width  = TestUtil.GetRandomInt(100, 500);
            int height = TestUtil.GetRandomInt(100, 500);

            nestedControl.Size = new Size(width, height);
            //---------------Assert Precondition----------------
            Assert.AreEqual(width, nestedControl.Width);
            Assert.AreEqual(height, nestedControl.Height);
            //---------------Execute Test ----------------------
            IControlHabanero dialogControl = okCancelDialogFactory.CreateOKCancelPanel(nestedControl);

            //---------------Test Result -----------------------
            Assert.AreEqual(width, nestedControl.Width, "Width should not have changed");
            Assert.AreEqual(height, nestedControl.Height, "Height should not have changed");
        }