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)); }
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_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"); }