public void Test_NoPropDefSet_ThrowsError()
        {
            //---------------Set up test pack-------------------
            SimpleLookupList simpleLookupList = new SimpleLookupList(_collection);

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            try
            {
                simpleLookupList.GetIDValueLookupList();
                Assert.Fail("expected Err");
            }
            //---------------Test Result -----------------------
            catch (Exception ex)
            {
                StringAssert.Contains("There is an application setup error. There is no propdef set for the simple lookup list.", ex.Message);
            }
            //---------------Test Result -----------------------

        }
        public void Test_SetValue_SetLookupValue_WhereIsAStringThatCanBeParsedToInt()
        {
            //This test is a compromise we cannot get this test and
            //Test_SetValue_SetLookupValue_WhereIsAStringThatCanBeParsedToInt_ExistsAsAnotherValueInList working
            // as well as the string property working since they have mutually exclusive logic.
            // We have compromised by allowing this test to not set the lookup value correctly and to return a null
            // The most common use of lookups in guids and strings and it works reliably for these scenarious.
            //   The final result is that if a developer has a lookup list where the display values are integers
            //   the lookup will not work reliably.
            //---------------Set up test pack-------------------
            const int validInt = 5;
            PropDef propDef1 = new PropDef("PropName", typeof(int), PropReadWriteRule.ReadWrite, null);
            const int validLookupValue_ThatIsAnInt = 555;
            Dictionary<string, string> collection_int = new Dictionary<string, string> { { validLookupValue_ThatIsAnInt.ToString(), validInt.ToString() } };
            SimpleLookupList simpleLookupList = new SimpleLookupList(collection_int);
            propDef1.LookupList = simpleLookupList;
            PropDef propDef = propDef1;
            BOProp boProp = new BOPropLookupList(propDef);
            //---------------Assert Precondition----------------
            Assert.IsNull(boProp.Value);
            Assert.IsTrue(simpleLookupList.GetIDValueLookupList().ContainsKey(validInt.ToString()));
            Assert.IsTrue(simpleLookupList.GetIDValueLookupList().ContainsValue(validLookupValue_ThatIsAnInt.ToString()));
            //---------------Execute Test ----------------------
            boProp.Value = validLookupValue_ThatIsAnInt;
            //---------------Test Result -----------------------
            Assert.AreEqual(validInt, boProp.Value);
            object propertyValueToDisplay = boProp.PropertyValueToDisplay;
            Assert.AreEqual(validLookupValue_ThatIsAnInt.ToString(), propertyValueToDisplay);
            Assert.IsTrue(boProp.IsValid);
            //            object validInt = boProp.PropertyValueToDisplay;
//            Assert.AreEqual(null, propertyValueToDisplay);
//            Assert.IsFalse(boProp.IsValid);
        }
 public void Test_SetValue_SetLookupValue_WhereIsAStringThatCanBeParsedToInt_ExistsAsAnotherValueInList()
 {
     //---------------Set up test pack-------------------
     const int validInt = 5;
     PropDef propDef1 = new PropDef("PropName", typeof(int), PropReadWriteRule.ReadWrite, null);
     const int validLookupValue_ThatIsAnInt = 555;
     Dictionary<string, string> collection_int = new Dictionary<string, string>
             {
                 { validLookupValue_ThatIsAnInt.ToString(), validInt.ToString() },
                 { validInt.ToString(), "999"}
             };
     SimpleLookupList simpleLookupList = new SimpleLookupList(collection_int);
     propDef1.LookupList = simpleLookupList;
     PropDef propDef = propDef1;
     BOProp boProp = new BOPropLookupList(propDef);
     //---------------Assert Precondition----------------
     Assert.IsNull(boProp.Value);
     Assert.IsTrue(simpleLookupList.GetIDValueLookupList().ContainsKey(validInt.ToString()));
     Assert.IsTrue(simpleLookupList.GetIDValueLookupList().ContainsValue(validLookupValue_ThatIsAnInt.ToString()));
     //---------------Execute Test ----------------------
     boProp.Value = validInt;
     //---------------Test Result -----------------------
     Assert.AreEqual(validInt, boProp.Value);
     object propertyValueToDisplay = boProp.PropertyValueToDisplay;
     Assert.AreEqual(validLookupValue_ThatIsAnInt.ToString(), propertyValueToDisplay);
 }
 public void Test_SimpleLookupList_Int_GetValue_NotExists()
 {
     //---------------Set up test pack-------------------
     PropDef propDef = new PropDef("PropName", typeof(int), PropReadWriteRule.ReadWrite, null);
     const int validInt = 1;
     Dictionary<string, string> collection_int = new Dictionary<string, string> { { _validLookupValue, validInt.ToString() } };
     SimpleLookupList simpleLookupList = new SimpleLookupList(collection_int);
     propDef.LookupList = simpleLookupList;
     Dictionary<string, string> list = simpleLookupList.GetIDValueLookupList();
     //---------------Assert Precondition----------------
     Assert.AreSame(propDef, simpleLookupList.PropDef);
     //---------------Execute Test ----------------------
     string returnedValue;
     bool keyReturned = list.TryGetValue("3", out returnedValue);
     //---------------Test Result -----------------------
     Assert.IsFalse(keyReturned);
     Assert.IsNull(returnedValue);
 }
 public void Test_SimpleLookupList_Int_GuidPropType()
 {
     //---------------Set up test pack-------------------
     PropDef propDef = new PropDef("PropName", typeof(Guid), PropReadWriteRule.ReadWrite, null);
     const int validInt = 1;
     Dictionary<string, string> collection_int = new Dictionary<string, string> { { _validLookupValue, validInt.ToString() } };
     SimpleLookupList simpleLookupList = new SimpleLookupList(collection_int);
     propDef.LookupList = simpleLookupList;
     
     //---------------Assert Precondition----------------
     Assert.AreSame(propDef, simpleLookupList.PropDef);
     //---------------Execute Test ----------------------
     try
     {
         simpleLookupList.GetIDValueLookupList();
         Assert.Fail("expected Err");
     }
         //---------------Test Result -----------------------
     catch (HabaneroDeveloperException ex)
     {
         StringAssert.Contains("There is an application setup error Please contact your system administrator", ex.Message);
         StringAssert.Contains("There is a class definition setup error the simple lookup list has lookup value items that are not of type", ex.DeveloperMessage);
         StringAssert.Contains("Guid", ex.DeveloperMessage);
     }
 }
 public void Test_SimpleLookupList_GetValue_NotExists()
 {
     //---------------Set up test pack-------------------
     PropDef propDef = new PropDef("PropName", typeof(Guid), PropReadWriteRule.ReadWrite, null);
     SimpleLookupList simpleLookupList = new SimpleLookupList(_collection);
     propDef.LookupList = simpleLookupList;
     Dictionary<string, string> list = simpleLookupList.GetIDValueLookupList();
     //---------------Assert Precondition----------------
     Assert.IsInstanceOf(typeof(SimpleLookupList), propDef.LookupList);
     Assert.AreSame(propDef, simpleLookupList.PropDef);
     //---------------Execute Test ----------------------
     string returnedValue;
     bool keyReturned = list.TryGetValue(NewGuidAsStdString(), out returnedValue);
     //---------------Test Result -----------------------
     Assert.IsFalse(keyReturned);
     Assert.IsNull(returnedValue);
 }
 public void Test_SetLookupList_SetsUpKeyLookupList()
 {
     //---------------Set up test pack-------------------
     PropDef propDef = new PropDef("PropName", typeof(Guid), PropReadWriteRule.ReadWrite, null);
     SimpleLookupList simpleLookupList = new SimpleLookupList(_collection);
     //---------------Assert Precondition----------------
     Assert.IsInstanceOf(typeof(NullLookupList), propDef.LookupList);
     Assert.AreEqual(_collection.Count, simpleLookupList.GetLookupList().Count);
     //---------------Execute Test ----------------------
     propDef.LookupList = simpleLookupList;
     //---------------Test Result -----------------------
     Assert.IsInstanceOf(typeof(SimpleLookupList), propDef.LookupList);
     Assert.AreSame(propDef, simpleLookupList.PropDef);
     Assert.AreEqual(_collection.Count, simpleLookupList.GetLookupList().Count);
     Assert.AreEqual(_collection.Count, simpleLookupList.GetIDValueLookupList().Count);
 }
 public void Test_SimpleLookup_Create_SetsUpKeyLookupList()
 {
     //---------------Set up test pack-------------------
     PropDef propDef = new PropDef("PropName", typeof(Guid), PropReadWriteRule.ReadWrite, null);
     //---------------Assert Precondition----------------
     Assert.AreEqual(2, _collection.Count);
     //---------------Execute Test ----------------------
     SimpleLookupList simpleLookupList = new SimpleLookupList(_collection);
     simpleLookupList.PropDef = propDef;
     //---------------Assert Precondition----------------
     Assert.AreEqual(_collection.Count, simpleLookupList.GetLookupList().Count);
     Assert.IsNotNull(simpleLookupList.GetIDValueLookupList());
     Assert.AreEqual(2, simpleLookupList.GetIDValueLookupList().Count);
 }