public void TestDatabaseLookupListWithClassDef() { XmlDatabaseLookupListLoader loader = new XmlDatabaseLookupListLoader(new DtdLoader(), GetDefClassFactory()); MyBO.LoadDefaultClassDef(); ILookupList def = loader.LoadLookupList( @"<databaseLookupList sql=""Source"" class=""MyBO"" assembly=""Habanero.Test"" />"); IDatabaseLookupList source = (IDatabaseLookupList)def; Assert.AreEqual("MyBO", source.ClassName); Assert.AreEqual("Habanero.Test", source.AssemblyName); Assert.AreEqual(10000, source.TimeOut); }
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 TestPropertyWithDatabaseLookupList() { MyBO.LoadDefaultClassDef(); IPropDef def = _loader.LoadProperty( @"<property name=""TestProp""><databaseLookupList sql=""Source"" timeout=""100"" class=""MyBO"" assembly=""Habanero.Test"" /></property>"); Assert.IsInstanceOf(typeof(IDatabaseLookupList), def.LookupList, "LookupList should be of type IDatabaseLookupList but is of type " + def.LookupList.GetType().Name); IDatabaseLookupList source = (IDatabaseLookupList)def.LookupList; Assert.AreEqual("Source", source.SqlString, "LookupList should be the same as that specified in xml"); Assert.AreEqual(100, source.TimeOut); Assert.AreEqual("MyBO", source.ClassName); Assert.AreEqual("Habanero.Test", source.AssemblyName); }