GetLookupList() public méthode

Returns a lookup-list for all the business objects stored under the class definition held in this instance
public GetLookupList ( ) : string>.Dictionary
Résultat string>.Dictionary
        public void TestSortingByDefault()
        {
            BusinessObjectLookupList source = new BusinessObjectLookupList("Habanero.Test.BO", "ContactPersonTestBO");
            new PropDef("N", typeof(Guid), PropReadWriteRule.ReadWrite, null) {LookupList = source};
            Dictionary<string, string> col = source.GetLookupList(DatabaseConnection.CurrentConnection);
            ArrayList items = new ArrayList(col.Values);

            Assert.AreEqual(3, col.Count);
            AssertCorrectlySortedBusinessObjectInList(items, 0, "abc");
            AssertCorrectlySortedBusinessObjectInList(items, 1, "abcd");
            AssertCorrectlySortedBusinessObjectInList(items, 2, "zzz");
        }
            public void Test_GetLookupList_WhenSubType_AndIDDeclaredOnTheParent_ShouldLoad_FixBug867()
            {
                //---------------Set up test pack-------------------
                BusinessObjectLookupList businessObjectLookupList = new BusinessObjectLookupList(typeof(SubClass));
                new PropDef("N", typeof(Guid), PropReadWriteRule.ReadWrite, null) { LookupList = businessObjectLookupList };
                //---------------Assert Precondition----------------

                //---------------Execute Test ----------------------
                var lookupList = businessObjectLookupList.GetLookupList(false);
                //---------------Test Result -----------------------
                Assert.IsNotNull(lookupList);
            }
 public void Test_GetLookupList_WhenTimeOutHasNotExpired_ShouldNotReload()
 {
     //---------------Set up test pack-------------------
     BusinessObjectLookupList source = new BusinessObjectLookupList(typeof(ContactPersonTestBO));
     source.PropDef = new PropDef("name", typeof(string), PropReadWriteRule.ReadWrite, null);
     const int timeout = 200000;
     source.TimeOut = timeout;
     Dictionary<string, string> col = source.GetLookupList(DatabaseConnection.CurrentConnection);
     //---------------Assert Precondition----------------
     Assert.AreEqual(timeout, source.TimeOut);
     Assert.IsNotNull(col);
     //---------------Execute Test ----------------------
     Dictionary<string, string> col2 = source.GetLookupList(DatabaseConnection.CurrentConnection);
     //---------------Test Result -----------------------
     Assert.AreSame(col, col2, "Both collections should be the same since the timeout has not been reached");
 }
 public void Test_GetLookupList_WhenTimeoutExpired_ShouldReloadList()
 {
     BusinessObjectLookupList source = new BusinessObjectLookupList(typeof(ContactPersonTestBO), 100);
     source.PropDef = new PropDef("name", typeof(string), PropReadWriteRule.ReadWrite, null);
     Dictionary<string, string> col = source.GetLookupList(DatabaseConnection.CurrentConnection);
     Thread.Sleep(250);
     Dictionary<string, string> col2 = source.GetLookupList(DatabaseConnection.CurrentConnection);
     Assert.AreNotSame(col2, col);
 }
        public void TestNowDateStringCriteria()
        {
            DeleteAllContactPeople();
            BusinessObjectCollection<ContactPersonTestBO> myCol = new BusinessObjectCollection<ContactPersonTestBO>();
            myCol.LoadAll();
            Assert.AreEqual(0, myCol.Count);
            ContactPersonTestBO contactPerson1 = new ContactPersonTestBO();
            contactPerson1.Surname = "aaa";
            contactPerson1.DateOfBirth = DateTime.Now.AddMinutes(-1);
            contactPerson1.Save();
            ContactPersonTestBO contactPerson2 = new ContactPersonTestBO();
            contactPerson2.Surname = "bbb";
            contactPerson2.DateOfBirth = DateTime.Now.AddMinutes(-1);
            contactPerson2.Save();
            ContactPersonTestBO contactPerson3 = new ContactPersonTestBO();
            contactPerson3.Surname = "ccc";
            contactPerson3.DateOfBirth = DateTime.Now.AddMinutes(-1);
            contactPerson3.Save();

            //ContactPersonTestBO.ClearObjectManager();
            BusinessObjectLookupList businessObjectLookupList = new BusinessObjectLookupList("Habanero.Test.BO",
                                                                                             "ContactPersonTestBO", "DateOfBirth < 'Now'", "");
            businessObjectLookupList.PropDef = new PropDef("name", typeof(string), PropReadWriteRule.ReadWrite, null);
            Dictionary<string, string> col = businessObjectLookupList.GetLookupList(DatabaseConnection.CurrentConnection);
            Assert.AreEqual(3, col.Count);
            Assert.IsTrue(col.ContainsValue(GuidToString(contactPerson1.ID.GetAsGuid())));
            Assert.IsTrue(col.ContainsValue(GuidToString(contactPerson2.ID.GetAsGuid())));
            Assert.IsTrue(col.ContainsValue(GuidToString(contactPerson3.ID.GetAsGuid())));
            businessObjectLookupList = new BusinessObjectLookupList("Habanero.Test.BO",
                "ContactPersonTestBO", "DateOfBirth > 'now'", "")
                   {
                       PropDef = new PropDef ("name", typeof (string), PropReadWriteRule.ReadWrite, null)
                   };
            col = businessObjectLookupList.GetLookupList(DatabaseConnection.CurrentConnection);
            Assert.AreEqual(0, col.Count);
            ContactPersonTestBO contactPerson4 = new ContactPersonTestBO();
            contactPerson4.Surname = "ddd";
            contactPerson4.DateOfBirth = DateTime.Now.AddMinutes(5);
            contactPerson4.Save();
            businessObjectLookupList = new BusinessObjectLookupList("Habanero.Test.BO",
                "ContactPersonTestBO", "DateOfBirth > NOW", "");
            businessObjectLookupList.PropDef = new PropDef("name", typeof(string), PropReadWriteRule.ReadWrite, null);

            col = businessObjectLookupList.GetLookupList(DatabaseConnection.CurrentConnection);
            Assert.AreEqual(1, col.Count);
            Assert.IsTrue(col.ContainsValue(GuidToString(contactPerson4.ID.GetAsGuid())));
        }
        public void TestTodayDateStringCriteria_GreaterThanOrEqualTo()
        {
            //-------------Setup Test Pack ------------------
            DeleteAllContactPeople();
            BusinessObjectCollection<ContactPersonTestBO> myCol = new BusinessObjectCollection<ContactPersonTestBO>();
            myCol.LoadAll();
            DateTime today = DateTime.Today;
            ContactPersonTestBO.CreateSavedContactPerson(today.AddDays(-1), "aaa");
            ContactPersonTestBO.CreateSavedContactPerson(today, "bbb");
            ContactPersonTestBO contactPerson3 = ContactPersonTestBO.CreateSavedContactPerson(today.AddDays(1), "ccc");
            //ContactPersonTestBO.ClearObjectManager();
            BusinessObjectLookupList businessObjectLookupList = new BusinessObjectLookupList("Habanero.Test.BO",
                                    "ContactPersonTestBO", "DateOfBirth > 'TODAY'", "");
            businessObjectLookupList.PropDef = new PropDef("name", typeof(string), PropReadWriteRule.ReadWrite, null);

            //-------------Test Pre-conditions --------------
            Assert.AreEqual(0, myCol.Count);

            //-------------Execute test ---------------------
            Dictionary<string, string> col = businessObjectLookupList.GetLookupList(DatabaseConnection.CurrentConnection);

            //-------------Test Result ----------------------
            Assert.AreEqual(1, col.Count);
            Assert.IsTrue(col.ContainsValue(GuidToString(contactPerson3.ID.GetAsGuid())));
        }
 public void TestCriteria()
 {
     BusinessObjectLookupList source = new BusinessObjectLookupList("Habanero.Test.BO",
         "ContactPersonTestBO", "Surname='zzz'", "");
     source.PropDef = new PropDef("name", typeof(string), PropReadWriteRule.ReadWrite, null);
     Dictionary<string, string> col = source.GetLookupList(DatabaseConnection.CurrentConnection);
     Assert.AreEqual(1, col.Count);
 }
 public void TestCallingGetLookupListTwiceOnlyAccessesDbOnce()
 {
     BusinessObjectLookupList source = new BusinessObjectLookupList(typeof(ContactPersonTestBO));
     source.PropDef = new PropDef("name", typeof(string), PropReadWriteRule.ReadWrite, null);
     Dictionary<string, string> col = source.GetLookupList(DatabaseConnection.CurrentConnection);
     Dictionary<string, string> col2 = source.GetLookupList(DatabaseConnection.CurrentConnection);
     Assert.AreSame(col2, col);
 }
 public void TestGetLookupList() 
 {
     BusinessObjectLookupList source = new BusinessObjectLookupList(typeof (ContactPersonTestBO));
     source.PropDef = new PropDef("name", typeof (string), PropReadWriteRule.ReadWrite, null);
     Dictionary<string, string> col = source.GetLookupList(DatabaseConnection.CurrentConnection);
     Assert.AreEqual(3, col.Count);
     foreach (string o in col.Values) {
         Assert.AreSame(typeof(string), o.GetType());
         Guid parsedGuid;
         Assert.IsTrue(StringUtilities.GuidTryParse(o, out parsedGuid));
     }
 }