public void TestChangePropValueUpdatesBusObj() { //---------------Set up test pack------------------- IComboBox cmbox = GetControlFactory().CreateComboBox(); const string propName = "SampleLookupID"; LookupComboBoxMapper mapper = new LookupComboBoxMapper(cmbox, propName, false, GetControlFactory()); Sample s = new Sample(); mapper.LookupList = Sample.LookupCollection; Guid guidResult; StringUtilities.GuidTryParse(Sample.LookupCollection[LOOKUP_ITEM_1], out guidResult); s.SampleLookupID = guidResult; mapper.BusinessObject = s; //---------------Test Preconditions------------------- Assert.AreEqual(3, Sample.LookupCollection.Count); Assert.IsNotNull(mapper.LookupList); Assert.IsNotNull(cmbox.SelectedItem, "There should be a selected item to start with"); //---------------Execute Test ---------------------- s.SampleLookupID = (Guid)GetGuidValue(Sample.LookupCollection, LOOKUP_ITEM_2); mapper.UpdateControlValueFromBusinessObject(); //---------------Test Result ----------------------- Assert.IsNotNull(cmbox.SelectedItem); Assert.AreEqual(LOOKUP_ITEM_2, cmbox.SelectedItem, "Value is not set after changing bo prop Value"); }
public void TestConstructor() { //---------------Set up test pack------------------- IComboBox cmbox = GetControlFactory().CreateComboBox(); //---------------Execute Test ---------------------- const string propName = "SampleLookupID"; LookupComboBoxMapper mapper = new LookupComboBoxMapper(cmbox, propName, false, GetControlFactory()); //---------------Test Result ----------------------- Assert.AreSame(cmbox, mapper.Control); Assert.AreSame(propName, mapper.PropertyName); //---------------Tear Down ------------------------- }
///<summary> /// Constructs the mapper for <see cref="IExtendedComboBox"/>. ///</summary> public ExtendedComboBoxMapper (IExtendedComboBox ctl, string propName, bool isReadOnly, IControlFactory controlFactory) : base(ctl, propName, isReadOnly, controlFactory) { ExtendedComboBox = ctl; LookupComboBoxMapper = new LookupComboBoxMapper (ExtendedComboBox.ComboBox, propName, isReadOnly, controlFactory); ExtendedComboBox.Button.Click += delegate { ShowPopupForm(); PopupForm.Closed += HandlePopUpFormClosedEvent; PopupForm.ShowDialog(); }; }
public void TestChangePropValueUpdatesBusObj_WithoutCallingUpdateControlValue() { //---------------Set up test pack------------------- IComboBox cmbox = GetControlFactory().CreateComboBox(); const string propName = "SampleLookupID"; LookupComboBoxMapper mapper = new LookupComboBoxMapper(cmbox, propName, false, GetControlFactory()); Sample s = new Sample(); mapper.LookupList = Sample.LookupCollection; s.SampleLookupID = (Guid)GetGuidValue(Sample.LookupCollection, LOOKUP_ITEM_1); mapper.BusinessObject = s; //---------------Execute Test ---------------------- s.SampleLookupID = (Guid)GetGuidValue(Sample.LookupCollection, LOOKUP_ITEM_2); //---------------Test Result ----------------------- Assert.AreEqual(LOOKUP_ITEM_2, cmbox.SelectedItem, "Value is not set after changing bo prop"); //---------------Tear Down ------------------------- }
public override void TestChangeComboBoxDoesntUpdateBusinessObject() { //For Windows the value should be changed. //---------------Set up test pack------------------- IComboBox cmbox = GetControlFactory().CreateComboBox(); const string propName = "SampleLookupID"; LookupComboBoxMapper mapper = new LookupComboBoxMapper(cmbox, propName, false, GetControlFactory()); Sample s = new Sample(); Dictionary<string, string> collection = mapper.LookupList = GetLookupList(); Guid guidResult; StringUtilities.GuidTryParse(collection[LOOKUP_ITEM_1], out guidResult); s.SampleLookupID = guidResult; mapper.BusinessObject = s; //---------------Execute Test ---------------------- cmbox.SelectedItem = LOOKUP_ITEM_2; //---------------Test Result ----------------------- Assert.AreEqual(collection[LOOKUP_ITEM_2], s.SampleLookupID.ToString(), "For Windows the value should be changed"); }
public virtual void TestChangeComboBoxDoesntUpdateBusinessObject() { //---------------Set up test pack------------------- IComboBox cmbox = GetControlFactory().CreateComboBox(); const string propName = "SampleLookupID"; LookupComboBoxMapper mapper = new LookupComboBoxMapper(cmbox, propName, false, GetControlFactory()); Sample s = new Sample(); mapper.LookupList = Sample.LookupCollection; Guid guidResult; StringUtilities.GuidTryParse(Sample.LookupCollection[LOOKUP_ITEM_1], out guidResult); s.SampleLookupID = guidResult; mapper.BusinessObject = s; //---------------Execute Test ---------------------- cmbox.SelectedItem = LOOKUP_ITEM_2; //---------------Test Result ----------------------- Assert.AreEqual(Sample.LookupCollection[LOOKUP_ITEM_1], s.SampleLookupID.ToString()); //---------------Tear Down ------------------------- }
public void Test_KeyPressStrategy_UpdatesBusinessObject_WhenEnterKeyPressed() { //---------------Set up test pack------------------- ComboBoxWinStub cmbox = new ComboBoxWinStub(); const string propName = "SampleLookupID"; LookupComboBoxMapper mapper = new LookupComboBoxMapper(cmbox, propName, false, GetControlFactory()); mapper.MapperStrategy = GetControlFactory().CreateLookupKeyPressMapperStrategy(); Sample s = new Sample(); mapper.LookupList = Sample.LookupCollection; s.SampleLookupID = (Guid)GetGuidValue(Sample.LookupCollection, LOOKUP_ITEM_1); mapper.BusinessObject = s; //---------------Execute Test ---------------------- cmbox.Text = "Test2"; cmbox.CallSendKeyBob(); //---------------Test Result ----------------------- Assert.IsInstanceOf(typeof(ComboBoxKeyPressMapperStrategyWin), mapper.MapperStrategy); Assert.AreEqual((Guid)GetGuidValue(Sample.LookupCollection, LOOKUP_ITEM_2), s.SampleLookupID); }
public void TestKeyPressEventUpdatesBusinessObject_WithoutCallingApplyChanges() { //---------------Set up test pack------------------- ComboBoxWinStub cmbox = new ComboBoxWinStub(); const string propName = "SampleLookupID"; LookupComboBoxMapper mapper = new LookupComboBoxMapper(cmbox, propName, false, GetControlFactory()); Sample s = new Sample(); mapper.LookupList = Sample.LookupCollection; s.SampleLookupID = (Guid)GetGuidValue(Sample.LookupCollection, LOOKUP_ITEM_1); mapper.BusinessObject = s; //---------------Execute Test ---------------------- cmbox.Text = "Test2"; //---------------Test Result ----------------------- Assert.IsInstanceOf(typeof(ComboBoxDefaultMapperStrategyWin), mapper.MapperStrategy); Assert.AreEqual((Guid)GetGuidValue(Sample.LookupCollection, LOOKUP_ITEM_2), s.SampleLookupID); }
public void TestChangeComboBoxUpdatesBusinessObject() { //---------------Set up test pack------------------- IComboBox cmbox = GetControlFactory().CreateComboBox(); const string propName = "SampleLookupID"; LookupComboBoxMapper mapper = new LookupComboBoxMapper(cmbox, propName, false, GetControlFactory()); Sample s = new Sample(); mapper.LookupList = Sample.LookupCollection; s.SampleLookupID = (Guid)GetGuidValue(Sample.LookupCollection, LOOKUP_ITEM_1); mapper.BusinessObject = s; //---------------Execute Test ---------------------- cmbox.SelectedItem = LOOKUP_ITEM_2; mapper.ApplyChangesToBusinessObject(); //---------------Test Result ----------------------- Assert.AreEqual((Guid)GetGuidValue(Sample.LookupCollection, LOOKUP_ITEM_2), s.SampleLookupID); }
public void Test_SetLookupListNull_ShouldNotRaiseError_ShouldSetListToNullDictionary() { //---------------Set up test pack------------------- IComboBox cmbox = GetControlFactory().CreateComboBox(); LookupComboBoxMapper mapper = new LookupComboBoxMapper(cmbox, GetRandomString(), false, GetControlFactory()); //---------------Assert Precondition---------------- Assert.IsNotNull(mapper.LookupList); Assert.IsEmpty(mapper.LookupList); //---------------Execute Test ---------------------- mapper.LookupList = null; //---------------Test Result ----------------------- Assert.IsNotNull(mapper.LookupList); Assert.IsEmpty(mapper.LookupList); }
public void Test_SetLookupListNull_WhenHasItems_ShouldClearTheList() { //---------------Set up test pack------------------- IComboBox cmbox = GetControlFactory().CreateComboBox(); LookupComboBoxMapper mapper = new LookupComboBoxMapper(cmbox, GetRandomString(), false, GetControlFactory()) { LookupList = Sample.LookupCollection }; //---------------Assert Precondition---------------- Assert.IsNotNull(mapper.LookupList); Assert.IsNotEmpty(mapper.LookupList); //---------------Execute Test ---------------------- mapper.LookupList = null; //---------------Test Result ----------------------- Assert.IsNotNull(mapper.LookupList); Assert.IsEmpty(mapper.LookupList); }
/// <summary> /// Updates the value on the control from the corresponding property /// on the represented <see cref="IControlMapper.BusinessObject"/> /// </summary> protected override void InternalUpdateControlValueFromBo() { LookupComboBoxMapper.DoUpdateControlValueFromBO(); }
/// <summary> /// Updates the value on the control from the corresponding property /// on the represented <see cref="IControlMapper.BusinessObject"/> /// </summary> public override void UpdateControlValueFromBusinessObject() { LookupComboBoxMapper.UpdateControlValueFromBusinessObject(); }
/// <summary> /// Updates the properties on the represented business object /// </summary> public override void ApplyChangesToBusinessObject() { LookupComboBoxMapper.ApplyChangesToBusinessObject(); }
public void TestSetBusinessObject_Null_SetBusinessObject_FillsList_BUGFIX() { //---------------Set up test pack------------------- ClassDef.ClassDefs.Clear(); IComboBox cmbox = GetControlFactory().CreateComboBox(); const string propName = "SampleLookup2ID"; Sample.CreateClassDefWin(); LookupComboBoxMapper mapper = new LookupComboBoxMapper(cmbox, propName, false, GetControlFactory()); Sample sample = new Sample(); // mapper.LookupList = Sample.LookupCollection; // sample.SampleLookupID = (Guid)GetGuidValue(Sample.LookupCollection, LOOKUP_ITEM_1); mapper.BusinessObject = null; //---------------Assert Precondition---------------- Assert.IsTrue(string.IsNullOrEmpty(Convert.ToString(cmbox.SelectedItem))); Assert.AreEqual(1, cmbox.Items.Count); //---------------Execute Test ---------------------- mapper.BusinessObject = sample; //---------------Test Result ----------------------- Assert.AreEqual(3, Sample.LookupCollection.Count); Assert.AreEqual(3 + 1, cmbox.Items.Count); Assert.IsNull(cmbox.SelectedItem); }
public void Test_KeyPressStrategy_DoesNotUpdateBusinessObject_SelectedIndexChanged() { //---------------Set up test pack------------------- ComboBoxWinStub cmbox = new ComboBoxWinStub(); const string propName = "SampleLookupID"; LookupComboBoxMapper mapper = new LookupComboBoxMapper(cmbox, propName, false, GetControlFactory()); mapper.MapperStrategy = GetControlFactory().CreateLookupKeyPressMapperStrategy(); Sample s = new Sample(); mapper.LookupList = Sample.LookupCollection; s.SampleLookupID = (Guid)GetGuidValue(Sample.LookupCollection, LOOKUP_ITEM_1); mapper.BusinessObject = s; //---------------Execute Test ---------------------- cmbox.SelectedItem = LOOKUP_ITEM_2; //---------------Test Result ----------------------- Assert.IsInstanceOf(typeof(ComboBoxKeyPressMapperStrategyWin), mapper.MapperStrategy); Assert.AreEqual((Guid)GetGuidValue(Sample.LookupCollection, LOOKUP_ITEM_1), s.SampleLookupID); //---------------Tear Down ------------------------- }
public void Test_LookupList_AddItemToComboBox_SelectAdditionalItem_SetsBOPropValueToNull() { //---------------Set up test pack------------------- IComboBox cmbox = GetControlFactory().CreateComboBox(); const string propName = "SampleLookup2ID"; LookupComboBoxMapper mapper = new LookupComboBoxMapper(cmbox, propName, false, GetControlFactory()); Sample sample = new Sample(); mapper.BusinessObject = sample; cmbox.Items.Add("SomeItem"); //---------------Assert Preconditions--------------- Assert.AreEqual(5, cmbox.Items.Count); Assert.AreEqual("SomeItem", LastComboBoxItem(cmbox).ToString()); //---------------Execute Test ---------------------- cmbox.SelectedIndex = cmbox.Items.Count - 1; mapper.ApplyChangesToBusinessObject(); //---------------Test Result ----------------------- object value = sample.GetPropertyValue(propName); Assert.IsNull(value); }
public void TestUsingBOLookupListString() { //---------------Set up test pack------------------- IComboBox cmbox = GetControlFactory().CreateComboBox(); const string propName = "SampleLookup3ID"; LookupComboBoxMapper mapper = new LookupComboBoxMapper(cmbox, propName, false, GetControlFactory()); Sample sample = new Sample(); object sampleToSelect = Sample.BOLookupCollection[LOOKUP_ITEM_2]; sample.SetPropertyValue(propName, sampleToSelect); //---------------Execute Test ---------------------- mapper.LookupList = Sample.BOLookupCollection; mapper.BusinessObject = sample; //---------------Test Result ----------------------- Assert.AreEqual(4, cmbox.Items.Count); Assert.AreEqual(LOOKUP_ITEM_2, cmbox.SelectedItem); Assert.AreSame(sampleToSelect, cmbox.SelectedValue); }
public void TestUsingPropWithBOLookupList() { //---------------Set up test pack------------------- DataStoreInMemory store = new DataStoreInMemory(); BORegistry.DataAccessor = new DataAccessorInMemory(store); IComboBox cmbox = GetControlFactory().CreateComboBox(); const string propName = "SampleLookup2ID"; LookupComboBoxMapper mapper = new LookupComboBoxMapper(cmbox, propName, false, GetControlFactory()); Dictionary<string, string> collection = getLookupList(); Sample sample = new Sample(); sample.Save(); string boId = collection[LOOKUP_ITEM_2]; Assert.AreEqual(4, store.Count); IBusinessObject businessObject = BORegistry.DataAccessor.BusinessObjectLoader.GetBusinessObjectByValue<Sample>(boId); Sample sampleToSelect = (Sample)businessObject; sample.SetPropertyValue(propName, sampleToSelect); //--------------Assert Preconditions ------------- Assert.AreEqual(3, collection.Count); Assert.AreEqual(4, store.Count); //---------------Execute Test ---------------------- mapper.LookupList = collection; mapper.BusinessObject = sample; //---------------Test Result ----------------------- Assert.AreEqual(4, cmbox.Items.Count); Assert.AreEqual(LOOKUP_ITEM_2, cmbox.SelectedItem); Assert.AreEqual(sampleToSelect.ToString(), cmbox.SelectedValue); }
public void TestUsingPropWithLookupSource() { //---------------Set up test pack------------------- IComboBox cmbox = GetControlFactory().CreateComboBox(); const string propName = "SampleLookup2ID"; LookupComboBoxMapper mapper = new LookupComboBoxMapper(cmbox, propName, false, GetControlFactory()); //---------------Execute Test ---------------------- mapper.BusinessObject = new Sample(); cmbox.SelectedIndex = 2; //---------------Test Result ----------------------- Assert.AreEqual(4, cmbox.Items.Count); Assert.AreSame(typeof(string), cmbox.SelectedItem.GetType()); Assert.AreSame(typeof(string), cmbox.SelectedValue.GetType()); }
public void TestSetBusinessObject_Null_NullLookupListSet_DoesNotRaiseError_BUGFIX() { //---------------Set up test pack------------------- IComboBox cmbox = GetControlFactory().CreateComboBox(); const string propName = "SampleLookupID"; LookupComboBoxMapper mapper = new LookupComboBoxMapper(cmbox, propName, false, GetControlFactory()); //---------------Assert Precondition---------------- Assert.IsEmpty(mapper.LookupList); Assert.AreEqual(0, cmbox.Items.Count); Assert.IsNull(cmbox.SelectedItem); //---------------Execute Test ---------------------- mapper.BusinessObject = null; //---------------Test Result ----------------------- Assert.IsNull(cmbox.SelectedItem); Assert.AreEqual(1, cmbox.Items.Count, "Should have only the null item in it."); }
public void Test_ResetBusinessObj_WhenHasNullValueForProperty_WhenPreviousBOHadAValue_ShouldSetSelectedItemNull_BUGFIX() { //---------------Set up test pack------------------- IComboBox cmbox = GetControlFactory().CreateComboBox(); const string propName = "SampleLookupID"; LookupComboBoxMapper mapper = new LookupComboBoxMapper(cmbox, propName, false, GetControlFactory()); Sample s = new Sample(); mapper.LookupList = Sample.LookupCollection; s.SampleLookupID = (Guid)GetGuidValue(Sample.LookupCollection, LOOKUP_ITEM_1); mapper.BusinessObject = s; Sample sWithNullPropValue = new Sample(); //---------------Assert Precondition---------------- Assert.IsNotNull(cmbox.SelectedItem); Assert.AreEqual(LOOKUP_ITEM_1, cmbox.SelectedItem, "Item is not set."); Assert.AreEqual(s.SampleLookupID.ToString(), cmbox.SelectedValue, "Value is not set"); Assert.IsTrue(string.IsNullOrEmpty(sWithNullPropValue.GetPropertyValueString("SampleLookupID"))); //---------------Execute Test ---------------------- mapper.BusinessObject = sWithNullPropValue; //---------------Test Result ----------------------- TestUtil.AssertStringEmpty(Convert.ToString(cmbox.SelectedItem), "cmbox.SelectedItem", "there should be no item selected"); }
public void TestSetBusinessObject_Null_DoesNotRaiseError_BUGFIX() { //---------------Set up test pack------------------- IComboBox cmbox = GetControlFactory().CreateComboBox(); const string propName = "SampleLookupID"; LookupComboBoxMapper mapper = new LookupComboBoxMapper(cmbox, propName, false, GetControlFactory()); Sample s = new Sample(); mapper.LookupList = Sample.LookupCollection; s.SampleLookupID = (Guid)GetGuidValue(Sample.LookupCollection, LOOKUP_ITEM_1); //---------------Assert Precondition---------------- Assert.AreEqual(3, Sample.LookupCollection.Count); Assert.IsNull(cmbox.SelectedItem); //---------------Execute Test ---------------------- mapper.BusinessObject = null; //---------------Test Result ----------------------- Assert.IsTrue(string.IsNullOrEmpty(Convert.ToString(cmbox.SelectedItem))); }
public void TestSetLookupList() { //---------------Set up test pack------------------- IComboBox cmbox = GetControlFactory().CreateComboBox(); const string propName = "SampleLookupID"; LookupComboBoxMapper mapper = new LookupComboBoxMapper(cmbox, propName, false, GetControlFactory()); new Sample(); //---------------Execute Test ---------------------- mapper.LookupList = Sample.LookupCollection; //---------------Test Result ----------------------- Assert.AreEqual(4, cmbox.Items.Count); //Assert.AreSame(typeof (string), cmbox.Items[0].GetType()); //Assert.IsTrue(cmbox.Items.Contains(LOOKUP_ITEM_1)); //---------------Tear Down ------------------------- }
public void TestSetBusinessObj() { //---------------Set up test pack------------------- IComboBox cmbox = GetControlFactory().CreateComboBox(); const string propName = "SampleLookupID"; LookupComboBoxMapper mapper = new LookupComboBoxMapper(cmbox, propName, false, GetControlFactory()); Sample s = new Sample(); mapper.LookupList = Sample.LookupCollection; s.SampleLookupID = (Guid)GetGuidValue(Sample.LookupCollection, LOOKUP_ITEM_1); //---------------Assert Precondition---------------- Assert.AreEqual(3, Sample.LookupCollection.Count); Assert.IsNull(cmbox.SelectedItem); //---------------Execute Test ---------------------- mapper.BusinessObject = s; //---------------Test Result ----------------------- Assert.IsNotNull(cmbox.SelectedItem); Assert.AreEqual(LOOKUP_ITEM_1, cmbox.SelectedItem, "Item is not set."); Assert.AreEqual(s.SampleLookupID.ToString(), cmbox.SelectedValue, "Value is not set"); }