public void Test_GetValue_FromKeyValueList_Sorted()
        {
            //---------------Set up test pack-------------------
            MyBO.LoadDefaultClassDef();
            BusinessObjectLookupList businessObjectLookupList = new BusinessObjectLookupListStub
                (typeof (MyBO), _collection, "TestProp");
            new PropDef("PropName", typeof (Guid), PropReadWriteRule.ReadWrite, null)
                {LookupList = businessObjectLookupList};
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            Dictionary<string, string> idValueLookupList = businessObjectLookupList.GetIDValueLookupList();

            //---------------Test Result -----------------------
            Assert.AreEqual(1, idValueLookupList.Count, "There should be one item in the lookup list");
            string guid = _validBusinessObject.ID.GetAsGuid().ToString();
            Assert.IsTrue(idValueLookupList.ContainsKey(guid));
            string returnedValue = idValueLookupList[guid];
            Assert.AreEqual(_validLookupValue, returnedValue);
        }
 public void Test_BusinessObjectLookupList_GetValue_Exists()
 {
     //---------------Set up test pack-------------------
     MyBO.LoadDefaultClassDef();
     PropDef propDef = new PropDef("PropName", typeof (Guid), PropReadWriteRule.ReadWrite, null);
     BusinessObjectLookupList businessObjectLookupList = new BusinessObjectLookupListStub
         (typeof (MyBO), _collection);
     propDef.LookupList = businessObjectLookupList;
     Dictionary<string, string> list = businessObjectLookupList.GetIDValueLookupList();
     //---------------Assert Precondition----------------
     Assert.IsInstanceOf(typeof (BusinessObjectLookupList), propDef.LookupList);
     Assert.AreSame(propDef, businessObjectLookupList.PropDef);
     //---------------Execute Test ----------------------
     string returnedValue;
     bool keyReturned = list.TryGetValue(_validBusinessObject.ID.GetAsGuid().ToString(), out returnedValue);
     //---------------Test Result -----------------------
     Assert.IsTrue(keyReturned);
     Assert.AreEqual(_validLookupValue, returnedValue);
 }
 public void Test_SimpleLookup_Create_SetsUpKeyLookupList_BO_PrimaryKeyNotSet()
 {
     //---------------Set up test pack-------------------
     OrganisationTestBO.LoadDefaultClassDef_WithSingleRelationship();
     OrganisationTestBO bo = new OrganisationTestBO {OrganisationID = null};
     BusinessObjectCollection<OrganisationTestBO> collectionBO =
         new BusinessObjectCollection<OrganisationTestBO> {bo};
     //---------------Assert Precondition----------------
     Assert.IsNull(bo.ID.GetAsValue());
     //---------------Execute Test ----------------------
     try
     {
         BusinessObjectLookupList businessObjectLookupList = new BusinessObjectLookupListStub
             (typeof (OrganisationTestBO), collectionBO) {PropDef = _propDefGuid};
         businessObjectLookupList.GetIDValueLookupList();
         Assert.Fail("expected Err");
     }
         //---------------Test Result -----------------------
     catch (HabaneroDeveloperException ex)
     {
         string developerMessage = string.Format
             ("A business object of '{0}' is being added to a lookup list for {1} it "
              + "does not have a value for its primary key set", _propDefGuid.PropertyTypeName,
              _propDefGuid.PropertyName);
         StringAssert.Contains(developerMessage, ex.DeveloperMessage);
     }
 }
 public void Test_SetLookupList_SetsUpKeyLookupList()
 {
     //---------------Set up test pack-------------------
     MyBO.LoadDefaultClassDef();
     PropDef propDef = new PropDef("PropName", typeof (Guid), PropReadWriteRule.ReadWrite, null);
     BusinessObjectLookupList businessObjectLookupList = new BusinessObjectLookupListStub
         (typeof (MyBO), _collection) {PropDef = _propDefGuid};
     //---------------Assert Precondition----------------
     Assert.IsInstanceOf(typeof (NullLookupList), propDef.LookupList);
     Assert.AreEqual(_collection.Count, businessObjectLookupList.GetLookupList().Count);
     //---------------Execute Test ----------------------
     propDef.LookupList = businessObjectLookupList;
     //---------------Test Result -----------------------
     Assert.IsInstanceOf(typeof (BusinessObjectLookupList), propDef.LookupList);
     Assert.AreSame(propDef, businessObjectLookupList.PropDef);
     Assert.AreEqual(_collection.Count, businessObjectLookupList.GetLookupList().Count);
     Assert.AreEqual(_collection.Count, businessObjectLookupList.GetIDValueLookupList().Count);
 }
 public void Test_SimpleLookup_Create_SetsUpKeyLookupList()
 {
     //---------------Set up test pack-------------------
     MyBO.LoadDefaultClassDef();
     //---------------Assert Precondition----------------
     Assert.AreEqual(1, _collection.Count);
     //---------------Execute Test ----------------------
     BusinessObjectLookupList businessObjectLookupList = new BusinessObjectLookupListStub
         (typeof (MyBO), _collection);
     businessObjectLookupList.PropDef = _propDefGuid;
     //---------------Assert Precondition----------------
     Assert.AreEqual(_collection.Count, businessObjectLookupList.GetLookupList().Count);
     Assert.IsNotNull(businessObjectLookupList.GetIDValueLookupList());
     Assert.AreEqual(_collection.Count, businessObjectLookupList.GetIDValueLookupList().Count);
 }