public void TestSimpleLookupListOptions()
        {
            ILookupList lookupList =
                _loader.LoadLookupList(
                    @"<simpleLookupList options=""option1|option2|option3"" />");
            ISimpleLookupList source = (ISimpleLookupList)lookupList;

            Assert.AreEqual(3, source.GetLookupList().Count, "LookupList should have three keyvaluepairs");
        }
        public void TestSimpleLookupListOptionsAndItems()
        {
            ILookupList lookupList =
                _loader.LoadLookupList(
                    @"
						<simpleLookupList options=""option1|option2|option3"" >
							<item display=""s1"" value=""{C2887FB1-7F4F-4534-82AB-FED92F954783}"" />
							<item display=""s2"" value=""{B89CC2C9-4CBB-4519-862D-82AB64796A58}"" />
                        </simpleLookupList>
					"                    );
            ISimpleLookupList source = (ISimpleLookupList)lookupList;

            Assert.AreEqual(5, source.GetLookupList().Count, "LookupList should have 5 keyvaluepairs");
        }
        private static void createLookupListXml(XmlElement propDMElement, IPropDef propDef)
        {
            ILookupList lookupListBase = propDef.LookupList;

            if (lookupListBase == null)
            {
                return;
            }
            //IClassDef lookupClass = lookupList.LookupClass;
            XmlElement lookupElement;

            if (lookupListBase is ISimpleLookupList)
            {
                ISimpleLookupList lookupList = (ISimpleLookupList)lookupListBase;

                lookupElement = XmlUtilities.createXmlElement(propDMElement, "simpleLookupList");
                foreach (KeyValuePair <string, string> pair in lookupList.GetLookupList())
                {
                    XmlElement addElement = XmlUtilities.createXmlElement(lookupElement, "item");
                    XmlUtilities.setXmlAttribute(addElement, "display", pair.Key);
                    XmlUtilities.setXmlAttribute(addElement, "value", pair.Value);
                }
            }

            if (lookupListBase is IDatabaseLookupList)
            {
                IDatabaseLookupList lookupList = (IDatabaseLookupList)lookupListBase;
                lookupElement = XmlUtilities.createXmlElement(propDMElement, "databaseLookupList");
                XmlUtilities.setXmlAttribute(lookupElement, "sql", lookupList.SqlString);
                XmlUtilities.setXmlAttribute(lookupElement, "timeout", lookupList.TimeOut, 10000);
                XmlUtilities.setXmlAttribute(lookupElement, "class", lookupList.ClassName);
                XmlUtilities.setXmlAttribute(lookupElement, "assembly", lookupList.AssemblyName);
            }

            if (lookupListBase is IBusinessObjectLookupList)
            {
                IBusinessObjectLookupList lookupList = (IBusinessObjectLookupList)lookupListBase;
                lookupElement = XmlUtilities.createXmlElement(propDMElement, "businessObjectLookupList");
                XmlUtilities.setXmlAttribute(lookupElement, "class", lookupList.ClassName);
                XmlUtilities.setXmlAttribute(lookupElement, "assembly", lookupList.AssemblyName);
                XmlUtilities.setXmlAttribute(lookupElement, "criteria", lookupList.CriteriaString);
                XmlUtilities.setXmlAttribute(lookupElement, "timeout", lookupList.TimeOut, 10000);
                //TODO Mark 28 Sep 2009: Check that this sort string is getting built correctly
                XmlUtilities.setXmlAttribute(lookupElement, "sort", lookupList.SortString);
            }
        }
        public virtual void TestPropertyWithSimpleLookupList()
        {
            IPropDef def =
                _loader.LoadProperty(
                    @"
					<property  name=""TestProp"">
						<simpleLookupList>
							<item display=""s1"" value=""{C2887FB1-7F4F-4534-82AB-FED92F954783}"" />
							<item display=""s2"" value=""{B89CC2C9-4CBB-4519-862D-82AB64796A58}"" />
						</simpleLookupList>
					</property>"                    );

            Assert.IsInstanceOf(typeof(ISimpleLookupList), def.LookupList,
                                "LookupList should be of type SimpleLookupList");
            ISimpleLookupList source = (ISimpleLookupList)def.LookupList;

            Assert.AreEqual(2, source.GetLookupList().Count, "LookupList should have two keyvaluepairs");
        }
        public void TestSimpleLookupListItems()
        {
            ILookupList lookupList =
                _loader.LoadLookupList(
                    @"
						<simpleLookupList>
							<item display=""s1"" value=""{C2887FB1-7F4F-4534-82AB-FED92F954783}"" />
							<item display=""s2"" value=""{B89CC2C9-4CBB-4519-862D-82AB64796A58}"" />
                        </simpleLookupList>
					"                    );
            ISimpleLookupList           source     = (ISimpleLookupList)lookupList;
            Dictionary <string, string> dictionary = source.GetLookupList();

            Assert.AreEqual(2, dictionary.Count, "LookupList should have 2 keyvaluepairs");
            Assert.IsTrue(dictionary.ContainsKey("s1"), "should contain the display value 's1' as a key");
            Assert.AreEqual(new Guid("{C2887FB1-7F4F-4534-82AB-FED92F954783}").ToString("D"), dictionary["s1"]);
            Assert.IsTrue(dictionary.ContainsKey("s2"), "should contain the display value 's2' as a key");
            Assert.AreEqual(new Guid("{B89CC2C9-4CBB-4519-862D-82AB64796A58}").ToString("D"), dictionary["s2"]);
        }