Ejemplo n.º 1
0
        public void TestButtonWidthTwoButtons()
        {
            //---------------Set up test pack-------------------
            IButtonSizePolicy  buttonSizePolicy = CreateButtonSizePolicy();
            const string       buttonText       = "TestMustBeLongEnoughToBeGreaterThanTwelthOfScreen";
            IControlCollection buttonCollection = GetControlFactory().CreatePanel().Controls;
            IButton            btnTest1         = GetControlFactory().CreateButton("Test");

            DisposeOnTearDown(btnTest1);
            buttonCollection.Add(btnTest1);
            IButton btnTest2 = GetControlFactory().CreateButton(buttonText);

            DisposeOnTearDown(btnTest2);
            buttonCollection.Add(btnTest2);

            //---------------Execute Test ----------------------
            buttonSizePolicy.RecalcButtonSizes(buttonCollection);
            ////---------------Test Result -----------------------

            ILabel lbl = GetControlFactory().CreateLabel(buttonText);

            DisposeOnTearDown(lbl);
            Assert.AreEqual(lbl.PreferredWidth + 15, btnTest1.Width, "Button width is incorrect.");

            Assert.AreEqual(btnTest2.Width, btnTest1.Width, "Button width is incorrect.");
        }
        public void TestButtonWidthOneSmallButton_WinOnly()
        {
            //---------------Set up test pack-------------------
            IButtonSizePolicy  buttonSizePolicy = CreateButtonSizePolicy();
            IControlCollection buttonCollection = GetControlFactory().CreatePanel().Controls;
            IButton            btnTest          = GetControlFactory().CreateButton("A");

            buttonCollection.Add(btnTest);

            //---------------Execute Test ----------------------
            buttonSizePolicy.RecalcButtonSizes(buttonCollection);

            ////---------------Test Result -----------------------

            Assert.AreEqual(System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width / 24, btnTest.Width,
                            "Button width is incorrect - when buttons are very small they should instead be 1 24th of screen width.");
        }