public void Test_InternalUpdateControlValueFromBo_IfComboBoxNotSetup_CallSetUpComboBoxItems() { //---------------Set up test pack------------------- //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- EnumComboBoxMapper enumComboBoxMapper = CreateComboBox(ENUM_PROP_NAME, true); IComboBox comboBox = (IComboBox)enumComboBoxMapper.Control; //---------------Test Result ----------------------- Assert.AreEqual(4, comboBox.Items.Count); }
protected override EnumComboBoxMapper CreateComboBox(string propertyName, bool setBO) { EnumBO bo = new EnumBO(); ComboBoxWin comboBox = new ComboBoxWin(); IControlFactory controlFactory = new ControlFactoryWin(); EnumComboBoxMapper enumComboBoxMapper = new EnumComboBoxMapper(comboBox, propertyName, false, controlFactory); if (setBO) { enumComboBoxMapper.BusinessObject = bo; } return(enumComboBoxMapper); }
public void Test_SetupComboBoxItems_PopulatesComboBoxWithEmptyEnum_StillWorksFine() { //---------------Set up test pack------------------- //---------------Assert Precondition---------------- Assert.AreEqual(0, Enum.GetNames(typeof(TestEnumEmpty)).Length); //---------------Execute Test ---------------------- EnumComboBoxMapper enumComboBoxMapper = CreateComboBox(ENUM_PROP_NAME_EMPTY, true); IComboBox comboBox = (IComboBox)enumComboBoxMapper.Control; //---------------Test Result ----------------------- Assert.AreEqual(1, comboBox.Items.Count); Assert.AreEqual("", comboBox.Items[0].ToString()); }
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); }
public void Test_SetupComboBoxItems_PopulatesComboBoxWithEnum() { //---------------Set up test pack------------------- //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- EnumComboBoxMapper enumComboBoxMapper = CreateComboBox(ENUM_PROP_NAME, true); IComboBox comboBox = (IComboBox)enumComboBoxMapper.Control; //---------------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()); }
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); }
public void Test_SetupComboBoxItems_PopulatesComboBoxWithSpacedEnum() { //---------------Set up test pack------------------- //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- EnumComboBoxMapper enumComboBoxMapper = CreateComboBox(ENUM_PROP_NAME_PASCAL, true); IComboBox comboBox = (IComboBox)enumComboBoxMapper.Control; //---------------Test Result ----------------------- Assert.AreEqual(5, comboBox.Items.Count); Assert.AreEqual("", comboBox.Items[0].ToString()); Assert.AreEqual("Simple", comboBox.Items[1].ToString()); Assert.AreEqual("Double Double", comboBox.Items[2].ToString()); Assert.AreEqual("Number 11", comboBox.Items[3].ToString()); Assert.AreEqual("Class ID", comboBox.Items[4].ToString()); }
public void Test_SetupComboBoxItems_ExceptionThrownIfPropertyTypeNotEnum() { //---------------Set up test pack------------------- EnumComboBoxMapper enumComboBoxMapper = CreateComboBox(ENUM_PKPROP_NAME, false); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- try { enumComboBoxMapper.BusinessObject = new EnumBO(); //---------------Test Result ----------------------- Assert.Fail("Expected to throw an InvalidPropertyException"); } catch (HabaneroApplicationException ex) { StringAssert.Contains("EnumComboBoxMapper can only be used for an enum property type", ex.Message); } }
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 ----------------------- }