Exemple #1
0
        public void Test_InternalUpdateControlValueFromBo_IfNotNull_SelectsNonBlank()
        {
            //---------------Set up test pack-------------------
            EnumComboBoxMapper enumComboBoxMapper = CreateComboBox(ENUM_PROP_NAME, true);
            IComboBox          comboBox           = (IComboBox)enumComboBoxMapper.Control;
            EnumBO             enumBO             = (EnumBO)enumComboBoxMapper.BusinessObject;

            enumComboBoxMapper.SetupComboBoxItems();
            //---------------Assert Precondition----------------
            Assert.AreEqual(-1, comboBox.SelectedIndex);
            //---------------Execute Test ----------------------
            enumBO.EnumProp = TestEnum.Option3;
            //---------------Test Result -----------------------
            Assert.AreEqual(3, comboBox.SelectedIndex);
        }
Exemple #2
0
        public void Test_ApplyChangesToBusinessObject_SelectMinusOne_SetsPropertyToNull()
        {
            //---------------Set up test pack-------------------
            EnumComboBoxMapper enumComboBoxMapper = CreateComboBox(ENUM_PROP_NAME, true);
            IComboBox          comboBox           = (IComboBox)enumComboBoxMapper.Control;
            EnumBO             enumBO             = (EnumBO)enumComboBoxMapper.BusinessObject;

            enumComboBoxMapper.SetupComboBoxItems();
            enumBO.EnumProp = TestEnum.Option3;
            //---------------Assert Precondition----------------
            Assert.AreEqual(3, comboBox.SelectedIndex);
            Assert.AreEqual((object)TestEnum.Option3, enumBO.EnumProp.Value);
            //---------------Execute Test ----------------------
            comboBox.SelectedIndex = -1;
            //---------------Test Result -----------------------
            Assert.IsFalse(enumBO.EnumProp.HasValue);
        }
Exemple #3
0
        public void Test_SetupComboBoxItems_PopulatesComboBoxWithEnum_ClearsItemsOnRepopulation()
        {
            //---------------Set up test pack-------------------
            EnumComboBoxMapper enumComboBoxMapper = CreateComboBox(ENUM_PROP_NAME, true);
            IComboBox          comboBox           = (IComboBox)enumComboBoxMapper.Control;

            //---------------Assert Precondition----------------
            Assert.AreEqual(4, comboBox.Items.Count);
            //---------------Execute Test ----------------------
            enumComboBoxMapper.SetupComboBoxItems();
            //---------------Test Result -----------------------
            Assert.AreEqual(4, comboBox.Items.Count);
            Assert.AreEqual("", comboBox.Items[0].ToString());
            Assert.AreEqual("Option 1", comboBox.Items[1].ToString());
            Assert.AreEqual("Option 2", comboBox.Items[2].ToString());
            Assert.AreEqual("Option 3", comboBox.Items[3].ToString());
        }
Exemple #4
0
        public void Test_SetupComboBoxItems_BONotSet_ThrowsException()
        {
            //---------------Set up test pack-------------------
            EnumComboBoxMapper enumComboBoxMapper = CreateComboBox(ENUM_PROP_NAME, false);

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            try
            {
                enumComboBoxMapper.SetupComboBoxItems();
                //---------------Test Result -----------------------
                Assert.Fail("Expected to throw an InvalidOperationException");
            }
            catch (InvalidOperationException ex)
            {
                StringAssert.Contains("The BusinessObject must be set on the EnumComboBoxMapper before calling SetupComboBoxItems", ex.Message);
            }
            //---------------Test Result -----------------------
        }