public void Test_InialiseProp_ValidGuidString() { //---------------Set up test pack------------------- BOProp boProp = new BOPropLookupList(_propDef_guid); //---------------Assert Precondition---------------- Assert.IsNull(boProp.Value); //---------------Execute Test ---------------------- boProp.InitialiseProp(_validGuid.ToString()); //---------------Test Result ----------------------- Assert.AreEqual(_validGuid, boProp.Value); Assert.AreEqual(_validLookupValue, boProp.PropertyValueToDisplay); }
public void Test_InialiseProp_EmptyGuid() { //---------------Set up test pack------------------- BOProp boProp = new BOPropLookupList(_propDef_guid); //---------------Assert Precondition---------------- Assert.IsNull(boProp.Value); //---------------Execute Test ---------------------- boProp.InitialiseProp(Guid.Empty); //---------------Test Result ----------------------- Assert.IsNull(boProp.Value); }
public void Test_InialiseProp_ValidGuidString_InList() { //---------------Set up test pack------------------- MyBO.LoadDefaultClassDef(); BOProp boProp = new BOPropLookupList(_propDefGuid); //---------------Assert Precondition---------------- Assert.IsNull(boProp.Value); //---------------Execute Test ---------------------- boProp.InitialiseProp(_validBusinessObject.ID.GetAsValue().ToString()); //---------------Test Result ----------------------- Assert.IsInstanceOf(typeof (Guid), boProp.Value); Assert.AreEqual(_validBusinessObject.ID.GetAsValue(), boProp.Value); Assert.AreEqual(_validLookupValue, boProp.PropertyValueToDisplay); Assert.IsTrue(string.IsNullOrEmpty(boProp.IsValidMessage)); Assert.IsTrue(boProp.IsValid); }
public void Test_BOPropLookupList_Int_PropValueToDisplay_InvalidInt() { //GetPropertyValueToDisplay where the guid value is not // in the lookup list (should return null) //---------------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; BOProp boProp = new BOPropLookupList(propDef); boProp.InitialiseProp(3); //---------------Assert Precondition---------------- Assert.IsNotNull(boProp.Value); Assert.AreEqual(3, boProp.Value); Assert.IsFalse(boProp.IsDirty); //---------------Execute Test ---------------------- object propertyValueToDisplay = boProp.PropertyValueToDisplay; //---------------Test Result ----------------------- Assert.IsNull(propertyValueToDisplay); }
public void Test_BOPropLookupList_Int_PropValueToDisplay_InvalidInt() { //GetPropertyValueToDisplay where the guid value is not // in the lookup list (should return null) //---------------Set up test pack------------------- BOProp boProp = new BOPropLookupList(GetPropDef_Int_WithLookupList()); int intNotInLookupList = _validIntID + 22; boProp.InitialiseProp(intNotInLookupList); boProp.Validate(); //---------------Assert Precondition---------------- Assert.IsNotNull(boProp.Value); Assert.AreEqual(intNotInLookupList, boProp.Value); Assert.IsFalse(boProp.IsValid); //---------------Execute Test ---------------------- object propertyValueToDisplay = boProp.PropertyValueToDisplay; //---------------Test Result ----------------------- Assert.IsNull(propertyValueToDisplay); }
public void Test_Initialise_InvalidString() { BOProp boProp = new BOPropLookupList(_propDef_int); const string invalid = "Invalid"; //---------------Assert Precondition---------------- Assert.AreEqual(typeof (int), _propDef_int.PropertyType); Assert.IsNull(boProp.Value); //---------------Execute Test ---------------------- try { boProp.InitialiseProp(invalid); Assert.Fail("expected Err"); } //---------------Test Result ----------------------- catch (HabaneroApplicationException ex) { StringAssert.Contains(boProp.PropertyName + " cannot be set to '" + invalid + "'", ex.Message); StringAssert.Contains("this value cannot be converted to a System.Int32", ex.Message); Assert.AreEqual(null, boProp.Value); Assert.IsTrue(boProp.IsValid); } }
public void Test_InialiseProp_ValidGuid() { //---------------Set up test pack------------------- BOProp boProp = new BOPropLookupList(_propDef_guid); //---------------Assert Precondition---------------- Assert.IsNull(boProp.Value); //---------------Execute Test ---------------------- boProp.InitialiseProp(_validID); //---------------Test Result ----------------------- Assert.IsNotNull(boProp.Value); Assert.IsInstanceOf(typeof (Guid), boProp.Value); Assert.AreEqual(_validID, boProp.Value); Assert.AreEqual(_validLookupValue, boProp.PropertyValueToDisplay); }
public void Test_BOPropLookupList_Int_InitialiseProp_ValidBusinessObject() { //---------------Set up test pack------------------- BOProp boProp = new BOPropLookupList(GetPropDef_Int_WithLookupList()); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- boProp.InitialiseProp(_validBusinessObject); //---------------Test Result ----------------------- Assert.AreEqual(_validBusinessObject.ID.GetAsValue(), boProp.Value); Assert.IsInstanceOf(typeof (int), boProp.Value); }
public void Test_SetValue_BusinessObject_NotInBOManager_ToStringNull_BONotInList() { ContactPersonTestBO.LoadDefaultClassDef(); PropDef propDef = new PropDef("PropName", typeof (Guid), PropReadWriteRule.ReadWrite, null) {LookupList = new BusinessObjectLookupList(typeof (ContactPersonTestBO), "", "", true)}; BOProp boProp = new BOPropLookupList(propDef); boProp.InitialiseProp(_validBusinessObject.ID.GetAsGuid()); ContactPersonTestBO boWithNullToString = new ContactPersonTestBO(); FixtureEnvironment.ClearBusinessObjectManager(); //---------------Assert Precondition---------------- Assert.AreEqual(typeof (Guid), propDef.PropertyType); Assert.IsTrue(boProp.IsValid); //---------------Execute Test ---------------------- boProp.Value = boWithNullToString; //---------------Test Result ----------------------- Assert.AreEqual(boWithNullToString.ContactPersonID, boProp.Value); string expectedErrorMessage = String.Format ("{0}' invalid since '{1}' is not in the lookup list of available values.", boProp.DisplayName, boProp.Value); StringAssert.Contains(expectedErrorMessage, boProp.IsValidMessage); Assert.IsFalse(boProp.IsValid); }
public void Test_BOPropLookupList_InitialiseProp_ValidID() { //---------------Set up test pack------------------- BOProp boProp = new BOPropLookupList(GetPropDef_Guid_WithLookupList()); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- boProp.InitialiseProp(_validID); //---------------Test Result ----------------------- Assert.AreEqual(_validID, boProp.Value); Assert.IsInstanceOf(typeof (Guid), boProp.Value); }
public void Test_InitialiseProp_ValidGuidString_NotInList() { //The business object property is loaded with the valid guid and is not placed in // an invalid state when it is initialised (loaded) from the database due to the performance overhead // and the potential for circular loading of lookup lists in the case of self referencing business objects //---------------Set up test pack------------------- MyBO.LoadDefaultClassDef(); BOProp boProp = new BOPropLookupList(_propDefGuid); //---------------Assert Precondition---------------- Assert.IsNull(boProp.Value); //---------------Execute Test ---------------------- boProp.InitialiseProp(_validBusinessObjectNotInList.ID.GetAsValue().ToString()); //---------------Test Result ----------------------- Assert.IsInstanceOf(typeof (Guid), boProp.Value); Assert.AreEqual(_validBusinessObjectNotInList.ID.GetAsValue(), boProp.Value); // string errorMessage = String.Format("'{0}' invalid since '{1}' is not in the lookup list of available values.", boProp.DisplayName, boProp.Value); // StringAssert.Contains(errorMessage, boProp.InvalidReason); Assert.AreEqual("", boProp.InvalidReason, "The business object is not placed in an invalid state"); Assert.IsTrue(boProp.IsValid); }
public void Test_InitialiseProp_ValidGuid_NotInList() { //---------------Set up test pack------------------- MyBO.LoadDefaultClassDef(); BOProp boProp = new BOPropLookupList(_propDefGuid); //---------------Assert Precondition---------------- Assert.IsNull(boProp.Value); //---------------Execute Test ---------------------- boProp.InitialiseProp(_validBusinessObjectNotInList.ID.GetAsValue()); //---------------Test Result ----------------------- Assert.IsNotNull(boProp.Value); Assert.IsInstanceOf(typeof (Guid), boProp.Value); Assert.AreEqual(_validBusinessObjectNotInList.ID.GetAsValue(), boProp.Value); // string errorMessage = String.Format("'{0}' invalid since '{1}' is not in the lookup list of available values.", boProp.DisplayName, boProp.Value); // StringAssert.Contains(errorMessage, boProp.InvalidReason); Assert.AreEqual("", boProp.InvalidReason, "The business object is not placed in an invalid state"); Assert.IsTrue(boProp.IsValid); }
public void Test_InitialiseProp_ValidDisplayValueString_PropTypeGuid() { //This test is testing the situation where a class definition is set up with a defualt value. //The default value is the lookup value and not the id value and the property type is // a guid then the initiale prop will raise an error since the default value could not be converte to a guid. MyBO.LoadDefaultClassDef(); BOProp boProp = new BOPropLookupList(_propDefGuid); PropDef propDef = (PropDef) boProp.PropDef; //---------------Assert Precondition---------------- Assert.AreEqual(typeof (Guid), propDef.PropertyType); Assert.IsNull(boProp.Value); //---------------Execute Test ---------------------- try { boProp.InitialiseProp(_validLookupValue); Assert.Fail("expected Err"); } //---------------Test Result ----------------------- catch (HabaneroApplicationException ex) { StringAssert.Contains("this value cannot be converted to a System.Guid", ex.Message); } // //---------------Test Result ----------------------- // Assert.AreEqual(_validBusinessObject.ID.GetAsValue(), boProp.Value); // Assert.AreEqual(_validLookupValue, boProp.PropertyValueToDisplay); }
public void Test_InitialiseProp_ValidDisplayValueString() { BOProp boProp = new BOPropLookupList(_propDef_guid); //---------------Assert Precondition---------------- Assert.AreEqual(typeof(Guid), _propDef_guid.PropertyType); Assert.IsNull(boProp.Value); //---------------Execute Test ---------------------- boProp.InitialiseProp(_validLookupValue); //---------------Test Result ----------------------- Assert.AreEqual(_validGuid, boProp.Value); Assert.AreEqual(_validLookupValue, boProp.PropertyValueToDisplay); }
public void Test_BOPropLookupList_PropValueToDisplay_ValidGuid() { //---------------Set up test pack------------------- BOProp boProp = new BOPropLookupList(_propDef_guid); boProp.InitialiseProp(_validGuid); //---------------Assert Precondition---------------- Assert.IsNotNull(boProp.Value); Assert.AreEqual(_validGuid, boProp.Value); //---------------Execute Test ---------------------- object propertyValueToDisplay = boProp.PropertyValueToDisplay; //---------------Test Result ----------------------- Assert.AreEqual(_validGuid, boProp.Value); Assert.AreEqual(_validLookupValue, propertyValueToDisplay); }
public void Test_BOPropLookupList_Int_PropValueToDisplay_NullValue() { //---------------Set up test pack------------------- BOProp boProp = new BOPropLookupList(GetPropDef_Int_WithLookupList()); boProp.InitialiseProp(null); //---------------Assert Precondition---------------- Assert.IsNull(boProp.Value); //---------------Execute Test ---------------------- object propertyValueToDisplay = boProp.PropertyValueToDisplay; //---------------Test Result ----------------------- Assert.IsNull(propertyValueToDisplay); }
public void Test_BOPropLookupList_PropValueToDisplay_InvalidGuid() { //GetPropertyValueToDisplay where the guid value is not // in the lookup list (should return null) //---------------Set up test pack------------------- BOProp boProp = new BOPropLookupList(_propDef_guid); Guid invalidGuid = Guid.NewGuid(); boProp.InitialiseProp(invalidGuid); //---------------Assert Precondition---------------- Assert.IsNotNull(boProp.Value); Assert.AreEqual(invalidGuid, boProp.Value); //---------------Execute Test ---------------------- object propertyValueToDisplay = boProp.PropertyValueToDisplay; //---------------Test Result ----------------------- Assert.IsNull( propertyValueToDisplay); }
public void Test_BOPropLookupList_Int_PropValueToDisplay_ValidInt() { //---------------Set up test pack------------------- BOProp boProp = new BOPropLookupList(GetPropDef_Int_WithLookupList()); boProp.InitialiseProp(_validBusinessObject.IntID); //---------------Assert Precondition---------------- Assert.IsNotNull(boProp.Value); Assert.AreEqual(_validBusinessObject.IntID, boProp.Value); //---------------Execute Test ---------------------- object propertyValueToDisplay = boProp.PropertyValueToDisplay; //---------------Test Result ----------------------- Assert.AreEqual(_validBusinessObject.IntID, boProp.Value); Assert.AreEqual(_validLookupValue, propertyValueToDisplay); }
public void Test_BOPropLookupList_PropValueToDisplay_ValidGuidStringLookUpList() { //---------------Set up test pack------------------- PropDef propDef = new PropDef("PropName", typeof(Guid), PropReadWriteRule.ReadWrite, null); propDef.LookupList = new SimpleLookupList(_collection_GuidString); BOProp boProp = new BOPropLookupList(propDef); Guid guid = _validGuid; //---------------Assert Precondition---------------- Assert.IsNull(boProp.Value); //---------------Execute Test ---------------------- boProp.InitialiseProp(guid); //---------------Test Result ----------------------- Assert.AreEqual(guid, boProp.Value); Assert.AreEqual(_validLookupValue, boProp.PropertyValueToDisplay); }
public void Test_InialiseProp_ValidintString() { //---------------Set up test pack------------------- BOProp boProp = new BOPropLookupList(_propDef_int); int expectIntID = (int) _validBusinessObject.ID.GetAsValue(); //---------------Assert Precondition---------------- Assert.IsNull(boProp.Value); //---------------Execute Test ---------------------- boProp.InitialiseProp(expectIntID.ToString()); //---------------Test Result ----------------------- Assert.IsInstanceOf(typeof (int), boProp.Value); Assert.AreEqual(expectIntID, boProp.Value); Assert.AreEqual(_validLookupValue, boProp.PropertyValueToDisplay); }
public void Test_InitialiseProp_ValidGuidString_P() { //---------------Set up test pack------------------- BOProp boProp = new BOPropLookupList(_propDef_guid); Guid guid = Guid.NewGuid(); //---------------Assert Precondition---------------- Assert.IsNull(boProp.Value); //---------------Execute Test ---------------------- boProp.InitialiseProp(guid.ToString("P")); //---------------Test Result ----------------------- Assert.IsNotNull(boProp.Value); Assert.IsTrue(boProp.Value is Guid, "Value should be a guid"); Assert.AreEqual(guid, boProp.Value); }
public void Test_InitialiseProp_ValidDisplayValueString() { BOProp boProp = new BOPropLookupList(_propDef_int); //---------------Assert Precondition---------------- Assert.AreEqual(typeof (int), _propDef_int.PropertyType); Assert.IsNull(boProp.Value); //---------------Execute Test ---------------------- try { boProp.InitialiseProp(_validLookupValue); Assert.Fail("expected Err"); } //---------------Test Result ----------------------- catch (HabaneroApplicationException ex) { StringAssert.Contains("this value cannot be converted to a System.Int32", ex.Message); } // //---------------Test Result ----------------------- // Assert.AreEqual(_validBusinessObject.ID.GetAsValue(), boProp.Value); // Assert.AreEqual(_validLookupValue, boProp.PropertyValueToDisplay); }
public void Test_BOPropLookupList_PropValueToDisplay_ValidIntStringLookUpList() { //---------------Set up test pack------------------- PropDef propDef = new PropDef("PropName", typeof(string), PropReadWriteRule.ReadWrite, null) {LookupList = new DatabaseLookupList(_sql)}; BOProp boProp = new BOPropLookupList(propDef); //---------------Assert Precondition---------------- Assert.IsNull(boProp.Value); //---------------Execute Test ---------------------- boProp.InitialiseProp(_validID); //---------------Test Result ----------------------- Assert.IsInstanceOf(typeof(string), boProp.Value); Assert.AreEqual(_validID.ToString(), boProp.Value); Assert.AreEqual(_validLookupValue, boProp.PropertyValueToDisplay); }