コード例 #1
0
 private static Dictionary<string, string> GetLookupList()
 {
     Sample sample1 = new Sample();
     sample1.Save();
     Sample sample2 = new Sample();
     sample2.Save();
     Sample sample3 = new Sample();
     sample3.Save();
     return new Dictionary<string, string>
                {
                    {"Test3", sample3.ID.GetAsValue().ToString()},
                    {"Test2", sample2.ID.GetAsValue().ToString()},
                    {"Test1", sample1.ID.GetAsValue().ToString()}
                };
 }
コード例 #2
0
        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);
        }