public void Setup() { ClassDef.ClassDefs.Clear(); _boPropCol1 = new BOPropCol(); _keyDef1 = new KeyDef(); _boPropCol2 = new BOPropCol(); _keyDef2 = new KeyDef(); //Props for KeyDef 1 PropDef lPropDef = new PropDef("PropName", typeof(string), PropReadWriteRule.ReadWrite, null); _boPropCol1.Add(lPropDef.CreateBOProp(false)); _keyDef1.Add(lPropDef); lPropDef = new PropDef("PropName1", typeof(string), PropReadWriteRule.ReadWrite, null); _boPropCol1.Add(lPropDef.CreateBOProp(false)); _keyDef1.Add(lPropDef); //Props for KeyDef 2 lPropDef = new PropDef("PropName1", typeof(string), PropReadWriteRule.ReadWrite, null); _boPropCol2.Add(lPropDef.CreateBOProp(false)); _keyDef2.Add(lPropDef); lPropDef = new PropDef("PropName", typeof(string), PropReadWriteRule.ReadWrite, null); _boPropCol2.Add(lPropDef.CreateBOProp(false)); _keyDef2.Add(lPropDef); }
private new static ClassDef CreateClassDef() { PropDefCol lPropDefCol = new PropDefCol(); PropDef propDef = new PropDef("Radius", typeof(int), PropReadWriteRule.ReadWrite, null); lPropDefCol.Add(propDef); //propDef = new PropDef("ContactPersonID", typeof(Guid), PropReadWriteRule.WriteOnce, "ContactPersonID", null); //lPropDefCol.Add(propDef); KeyDefCol keysCol = new KeyDefCol(); RelationshipDefCol relDefCol = new RelationshipDefCol(); //RelKeyDef relKeyDef = new RelKeyDef(); //IPropDef relPropDef = lPropDefCol["ContactPersonID"]; //RelPropDef lRelPropDef = new RelPropDef(relPropDef, "ContactPersonID"); //relKeyDef.Add(lRelPropDef); //RelationshipDef relDef = new SingleRelationshipDef("ContactPerson", typeof(ContactPerson), relKeyDef, false, DeleteParentAction.DoNothing); //relDefCol.Add(relDef); ClassDef lClassDef = new ClassDef(typeof(CircleNoPrimaryKey), null, "circle_table", lPropDefCol, keysCol, relDefCol, null); //ClassDef lClassDef = new ClassDef(typeof(CircleNoPrimaryKey), null, lPropDefCol, keysCol, relDefCol); lClassDef.SuperClassDef = new SuperClassDef(Shape.GetClassDef(), ORMapping.ClassTableInheritance); ClassDef.ClassDefs.Add(lClassDef); return lClassDef; }
protected static PropDefCol CreateBOPropDef() { PropDefCol lPropDefCol = new PropDefCol(); PropDef propDef = new PropDef("Surname", typeof(String), PropReadWriteRule.ReadWrite, null); propDef.AddPropRule(new PropRuleString("ContactPerson-" + propDef.PropertyName, "", 2, 50, null)); lPropDefCol.Add(propDef); propDef = new PropDef("FirstName", typeof(String), PropReadWriteRule.ReadWrite, null); lPropDefCol.Add(propDef); propDef = new PropDef("DateOfBirth", typeof(DateTime), PropReadWriteRule.WriteOnce, null); lPropDefCol.Add(propDef); //Create concurrency control properties propDef = new PropDef("DateLastUpdated", typeof(DateTime), PropReadWriteRule.ReadWrite, DateTime.Now); lPropDefCol.Add(propDef); propDef = new PropDef("UserLastUpdated", typeof(string), PropReadWriteRule.ReadWrite, null); lPropDefCol.Add(propDef); propDef = new PropDef("MachineLastUpdated", typeof(string), PropReadWriteRule.ReadWrite, null); lPropDefCol.Add(propDef); propDef = new PropDef("VersionNumber", typeof(int), PropReadWriteRule.ReadWrite, 1); lPropDefCol.Add(propDef); propDef = new PropDef(PK1_PROP1_NAME, typeof(string), PropReadWriteRule.ReadWrite, "PK1_Prop1", null); lPropDefCol.Add(propDef); propDef = new PropDef(PK1_PROP2_NAME, typeof(string), PropReadWriteRule.ReadWrite, "PK1_Prop2", null); lPropDefCol.Add(propDef); return(lPropDefCol); }
private static BOPrimaryKey CreatePrimaryBOKeyGuidAndString() { PropDef propDef1 = new PropDef("PropName1", typeof(Guid), PropReadWriteRule.ReadWrite, null) { ClassDef = ContactPersonTestBO.LoadDefaultClassDef() }; PropDef propDef2 = new PropDef("PropName2", typeof(string), PropReadWriteRule.ReadWrite, null) { ClassDef = propDef1.ClassDef }; BOPropCol propCol = new BOPropCol(); propCol.Add(propDef1.CreateBOProp(true)); propCol.Add(propDef2.CreateBOProp(true)); // BOPropCol propCol = new BOPropCol(); // propCol.Add(propDef1.CreateBOProp(true)); // propCol.Add(propDef2.CreateBOProp(true)); PrimaryKeyDef keyDef = new PrimaryKeyDef { IsGuidObjectID = false }; keyDef.Add(propDef1); keyDef.Add(propDef2); return((BOPrimaryKey)keyDef.CreateBOKey(propCol)); }
public void Test_SetValue_InvalidDateTimeString() { BOProp boProp = new BOProp(_propDef); const string invalid = "Invalid"; object originalPropValue = DateTime.MinValue.AddDays(1); boProp.Value = originalPropValue; PropDef propDef = (PropDef)boProp.PropDef; //---------------Assert Precondition---------------- Assert.AreEqual(typeof(DateTime), propDef.PropertyType); Assert.IsNotNull(boProp.Value); //---------------Execute Test ---------------------- try { boProp.Value = invalid; //expectedGuid.ToString("B"); Assert.Fail("expected Err"); } //---------------Test Result ----------------------- catch (HabaneroDeveloperException ex) { StringAssert.Contains(boProp.PropertyName + " cannot be set to " + invalid, ex.Message); StringAssert.Contains("It is not a type of ", ex.Message); StringAssert.Contains("DateTime", ex.Message); Assert.AreEqual(originalPropValue, boProp.Value); Assert.IsTrue(boProp.IsValid); } }
public void init() { mKeyDef = new KeyDef(); mKeyDef.IgnoreIfNull = true; PropDef lPropDef = new PropDef("PropName", typeof(string), PropReadWriteRule.ReadOnly, null); mKeyDef.Add(lPropDef); }
public static ClassDef CreateTestMapperClassDef() { PropDefCol lPropDefCol = new PropDefCol(); PropDef propDef = new PropDef("ShapeName", typeof(String), PropReadWriteRule.ReadWrite, "ShapeName", null); lPropDefCol.Add(propDef); propDef = new PropDef("ShapeID", typeof(Guid), PropReadWriteRule.WriteOnce, "ShapeID_field", null); lPropDefCol.Add(propDef); propDef = new PropDef("ShapeValue", typeof(Int32), PropReadWriteRule.ReadWrite, null); lPropDefCol.Add(propDef); // propDef = new PropDef("MyID", typeof(Guid), PropReadWriteRule.WriteOnce, null); // lPropDefCol.Add(propDef); PrimaryKeyDef primaryKey = new PrimaryKeyDef(); primaryKey.IsGuidObjectID = true; primaryKey.Add(lPropDefCol["ShapeID"]); KeyDefCol keysCol = new KeyDefCol(); KeyDef lKeyDef = new KeyDef(); lKeyDef.Add(lPropDefCol["ShapeName"]); keysCol.Add(lKeyDef); // RelKeyDef relKeyDef = new RelKeyDef(); //RelPropDef lRelPropDef = new RelPropDef(propDef, "OwnerID"); //relKeyDef.Add(lRelPropDef); //RelationshipDef relDef = new MultipleRelationshipDef("Owner", typeof (Shape), // relKeyDef, false, "", DeleteParentAction.DereferenceRelated); RelationshipDefCol relDefCol = new RelationshipDefCol(); //relDefCol.Add(relDef); ClassDef lClassDef = new ClassDef(typeof(Shape), primaryKey, "Shape_table", lPropDefCol, keysCol, relDefCol); ClassDef.ClassDefs.Add(lClassDef); return lClassDef; }
public void TestHasAutoIncrementingProperty_TwoProps_True() { //---------------Set up test pack------------------- PropDef propDef1 = new PropDef("PropName1", typeof(string), PropReadWriteRule.ReadWrite, null); PropDef propDef2 = new PropDef("PropName2", typeof(string), PropReadWriteRule.ReadWrite, null); propDef2.AutoIncrementing = true; BOPropCol propCol = new BOPropCol(); propCol.Add(propDef1.CreateBOProp(false)); propCol.Add(propDef2.CreateBOProp(false)); KeyDef keyDef = new KeyDef(); keyDef.Add(propDef1); keyDef.Add(propDef2); IBOKey boKey = keyDef.CreateBOKey(propCol); //---------------Assert PreConditions--------------- //---------------Execute Test ---------------------- bool hasAutoIncrementingProperty = boKey.HasAutoIncrementingProperty; //---------------Test Result ----------------------- Assert.IsTrue(hasAutoIncrementingProperty); //---------------Tear Down ------------------------- }
public void Test_Initialise_InvalidDateTimeString() { BOProp boProp = new BOProp(_propDef); const string invalid = "Invalid"; PropDef propDef = (PropDef)boProp.PropDef; //---------------Assert Precondition---------------- Assert.AreEqual(typeof(DateTime), propDef.PropertyType); Assert.IsNull(boProp.Value); //---------------Execute Test ---------------------- try { boProp.InitialiseProp(invalid); Assert.Fail("expected Err"); } //---------------Test Result ----------------------- catch (HabaneroDeveloperException ex) { StringAssert.Contains(boProp.PropertyName + " cannot be set to " + invalid, ex.Message); StringAssert.Contains("It is not a type of ", ex.Message); StringAssert.Contains("DateTime", ex.Message); Assert.AreEqual(null, boProp.Value); Assert.IsTrue(boProp.IsValid); } }
// --------------------------------------------------------------------------------------------------------------------------------------------------------------- /// <summary> /// Gets and possibly initializes, for the supplied Entity-Instance, its Edit-Engine based on the specified Current. /// </summary> public static EntityEditEngine ObtainEditEngine(IModelEntity EntityInstance, EntityEditEngine Current) { // IMPORTANT: Do not read Entity.AssignedEditEngine. An infinite-loop may occur. // Instead use the Current parameter. // PENDING: Solve mismatch crash for: // Change of document and immediate copy of objects. if (Current == null && ActiveEntityEditor != null && (ActiveEntityEditor.ExecutionStatus == EExecutionStatus.Running || ActiveEntityEditor.ExecutionStatus == EExecutionStatus.Created)) { EntityInstance.EditEngine = Current = ActiveEntityEditor; // Centralizes store-boxes references // IMPORTANT: The EntityEditor is used because exists while calling Constructors. So, do not use MainEditedEntity (Composition). if (Current != null) { foreach (var PropDef in EntityInstance.ClassDefinition.Properties.Where(prop => prop.IsStoreBoxBased)) { PropDef.GetStoreBoxContainer(EntityInstance).CentralizeReferencesIn(Current.GlobalId); } } } /*T ONLY RELEVANT WHEN MODIFYING VALUES. * SEE RegisterInverseAssignment() and RegisterInverseCollectionChange(). * else*/ /* * if (Current != ActiveEntityEditor) * Console.WriteLine("Active Entity-Editor differs from that of Entity '" + EntityInstance.ToStringAlways() + "'."); */ return(Current); }
internal List <Autodesk.Connectivity.WebServices.File> GetVaultFilesByFileName(string fileName) { List <Autodesk.Connectivity.WebServices.File> foundFiles = new List <Autodesk.Connectivity.WebServices.File>(); PropDef[] filePropDefs = _webServiceManager.PropertyService.GetPropertyDefinitionsByEntityClassId("FILE"); PropDef fileNamePropDef = filePropDefs.Single(n => n.SysName == "FileName"); SrchCond fileNameCond = new SrchCond() { PropDefId = fileNamePropDef.Id, PropTyp = PropertySearchType.SingleProperty, SrchOper = 3, SrchRule = SearchRuleType.Must, SrchTxt = fileName }; string bookmark = string.Empty; SrchStatus status = null; while (status == null || foundFiles.Count < status.TotalHits) { Autodesk.Connectivity.WebServices.File[] results = _webServiceManager.DocumentService.FindFilesBySearchConditions( new SrchCond[] { fileNameCond }, null, null, false, true, ref bookmark, out status); if (results != null) { foundFiles.AddRange(results); } else { break; } } return(foundFiles); }
public void Test_CreatePrimaryKey_TwoPropDefs() { //---------------Set up test pack------------------- PropDef propDef1 = new PropDef("prop1", typeof(String), PropReadWriteRule.ReadWrite, null); PropDef propDef2 = new PropDef("prop2", typeof(String), PropReadWriteRule.ReadWrite, null); PrimaryKeyDef keyDef = new PrimaryKeyDef { IsGuidObjectID = false }; keyDef.Add(propDef2); keyDef.Add(propDef1); BOPropCol boPropCol = new BOPropCol(); boPropCol.Add(propDef1.CreateBOProp(false)); boPropCol.Add(propDef2.CreateBOProp(false)); //---------------Assert Precondition---------------- Assert.AreEqual(2, keyDef.Count); //---------------Execute Test ---------------------- BOPrimaryKey boPrimaryKey = (BOPrimaryKey)keyDef.CreateBOKey(boPropCol); //---------------Test Result ----------------------- Assert.AreEqual(keyDef.Count, boPrimaryKey.Count); Assert.IsTrue(boPrimaryKey.IsCompositeKey); }
public void init() { PropDef propDef = new PropDef("Prop", typeof(string), PropReadWriteRule.ReadWrite, null); _relPropDef = new RelPropDef(propDef, "PropName"); _propDefCol = new PropDefCol(); _propDefCol.Add(propDef); }
private static PropDefCol CreateBOPropDef() { PropDefCol lPropDefCol = new PropDefCol(); PropDef propDef = new PropDef("TransactionSequenceNo", typeof(int), PropReadWriteRule.ReadWrite, null); lPropDefCol.Add(propDef); propDef = new PropDef("DateTimeUpdated", typeof(DateTime), PropReadWriteRule.ReadWrite, null); lPropDefCol.Add(propDef); propDef = new PropDef("WindowsUser", typeof(String), PropReadWriteRule.WriteOnce, null); lPropDefCol.Add(propDef); propDef = new PropDef("LogonUser", typeof(String), PropReadWriteRule.ReadOnly, null); lPropDefCol.Add(propDef); propDef = new PropDef("BusinessObjectTypeName", typeof(string), PropReadWriteRule.ReadOnly, null); lPropDefCol.Add(propDef); propDef = new PropDef("CRUDAction", typeof(string), PropReadWriteRule.ReadOnly, null); lPropDefCol.Add(propDef); propDef = new PropDef("DirtyXML", typeof(string), PropReadWriteRule.ReadOnly, null); lPropDefCol.Add(propDef); propDef = new PropDef("MachineName", typeof(string), PropReadWriteRule.ReadOnly, null); lPropDefCol.Add(propDef); return(lPropDefCol); }
public static PropDef getPropertyDefDetails(VDF.Vault.Currency.Connections.Connection connection, string entityClassIDs, string propertyName) { Dictionary <long, string> props = new Dictionary <long, string>(); try { using (WebServiceManager serviceManager = connection.WebServiceManager) //using will log out after usage { var propDefs = serviceManager.PropertyService.GetPropertyDefinitionsByEntityClassId(entityClassIDs); foreach (var item in propDefs) { //MessageBox.Show(propertyName + " == " + item.DispName + " | | | " + item.Id); if (item.DispName.Equals(propertyName)) { //MessageBox.Show(item.DispName + " | " + item.Id); propinfo = item; } } } } catch (SystemException ex) { MessageBox.Show(ex.ToString()); } return(propinfo); }
//public static implicit operator PropDef(PropDefBuilder builder) //{ // return new PropDef(PropertyName, PropertyTypeAssemblyName, PropertyTypeName, ReadWriteRule, DatabaseFieldName, DefaultValueString, _isCompulsory, _isAutoIncrementing); //} public IPropDef Build() { var propDef = new PropDef(PropertyName, PropertyTypeAssemblyName, PropertyTypeName , ReadWriteRule, DatabaseFieldName, DefaultValueString, _isCompulsory, _isAutoIncrementing, Int32.MaxValue, _displayName, _description, _keepValuePrivate); return(propDef); }
public void TestFixtureSetup() { //Code that is executed before any test is run in this class. If multiple tests // are executed then it will still only be called once. _propDef = new PropDef("PropName", typeof(string), PropReadWriteRule.ReadWrite, null); _dataMapper = new StringDataMapper(); }
public void TestFixtureSetup() { //Code that is executed before any test is run in this class. If multiple tests // are executed then it will still only be called once. _propDef = new PropDef("PropName", typeof (string), PropReadWriteRule.ReadWrite, null); _dataMapper = new StringDataMapper(); }
private static string ConstructMessage(PropDef propDef) { if (propDef == null) return ""; string displayName = String.IsNullOrEmpty(propDef.DisplayName) ? propDef.PropertyName : propDef.DisplayName; return String.Format("Error writing to property '{0}' because it is configured as a '{1}' property.", displayName, propDef.ReadWriteRule); }
public void Test_SimpleLookupList_Int_String_GetKey_Exists() { //---------------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.GetLookupList(); //---------------Assert Precondition---------------- Assert.IsInstanceOf(typeof(SimpleLookupList), propDef.LookupList); Assert.AreSame(propDef, simpleLookupList.PropDef); //---------------Execute Test ---------------------- string returnedKey; bool keyReturned = list.TryGetValue(_validLookupValue, out returnedKey); //---------------Test Result ----------------------- Assert.IsTrue(keyReturned); Assert.AreEqual(validInt.ToString(), returnedKey); }
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); }
private void loadDB(string fileName) { FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read); int count = ReadInt(fs); Classes = new List <ClassDef>(); pb1.Maximum = count + 1; for (int i = 0; i < count; i++) { if (i % 10 == 0) { pb1.Value = i; Application.DoEvents(); } ClassDef tmp = new ClassDef(); tmp.name = ReadString(fs); int pcount = ReadInt(fs); tmp.props = new List <PropDef>(); for (int j = 0; j < pcount; j++) { PropDef p = new PropDef(); p.name = ReadString(fs); p.type = ReadInt(fs); p.ffpath = ReadString(fs); p.ffidx = ReadInt(fs); tmp.props.Add(p); } Classes.Add(tmp); } fs.Close(); Sort(); RefreshLists(); Properties.Settings.Default.PropertyDBPath = fileName; }
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_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_WriteOnce_PersistedValueSet_IsEditable_False() { //---------------Set up test pack------------------- PropDef propDef = new PropDef("Name", typeof(string), PropReadWriteRule.WriteOnce, "DD", "", false, false); BOProp prop1 = new BOProp(propDef) { Value = "new Value", IsObjectNew = false }; prop1.BackupPropValue(); //---------------Assert Precondition---------------- Assert.AreEqual(PropReadWriteRule.WriteOnce, prop1.PropDef.ReadWriteRule); Assert.IsNotNull(prop1.PersistedPropertyValue); //---------------Execute Test ---------------------- string message; bool isEditable = prop1.IsEditable(out message); //---------------Test Result ----------------------- Assert.IsFalse(isEditable); StringAssert.Contains("The property ", message); StringAssert.Contains ("Name' is not editable since it is set up as WriteOnce and the value has already been set", message); }
public void Test_GetLookupList_LookupListIncorrectType() { //---------------Set up test pack------------------ PropDef propDef = new PropDef("PropName", typeof(int), PropReadWriteRule.ReadWrite, null); DatabaseLookupList databaseLookupList = new DatabaseLookupList(_sql); propDef.LookupList = databaseLookupList; //---------------Assert Precondition---------------- Assert.IsInstanceOf(typeof(DatabaseLookupList), propDef.LookupList); //---------------Execute Test ---------------------- try { databaseLookupList.GetLookupList(); 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 database lookup list has lookup value items that are not of type", ex.DeveloperMessage); StringAssert.Contains("Int32", ex.DeveloperMessage); } }
List <PropDef> ParsePropsFromJsV1() { string[] lines = GetCode().Split(new[] { "\r\n", "\r", "\n" }, System.StringSplitOptions.None); List <PropDef> result = new List <PropDef>(); foreach (string line in lines) { if (line.StartsWith("// property ")) { try { string[] parts = line.Split(' '); string initValueString = parts.Length > 4 ? parts[4] : null; PropDef prop = new PropDef { type = parts[2], variableName = parts[3], defaultValueString = initValueString }; result.Add(prop); } catch (System.Exception e) { Util.LogError($"Error while trying to parse property comment - will ignore it. The error: {e.ToString()}. The comment line: {line}"); } } } return(result); }
internal static MockBO CreateMockBOWithExtraReadOnlyProp(string newPropName) { ClassDef newClassDef = new MockBO().ClassDef.Clone(); PropDef def = new PropDef(newPropName, typeof (string), PropReadWriteRule.ReadOnly, ""); newClassDef.PropDefcol.Add(def); return new MockBO(newClassDef); }
private static ClassDef GetClassDef() { PropDef propDefPK = new PropDef(ENUM_PKPROP_NAME, typeof(Guid), PropReadWriteRule.WriteNew, null); PropDef propDef = new PropDef(ENUM_PROP_NAME, typeof(TestEnum), PropReadWriteRule.ReadWrite, TestEnum.Option1); PropDef propDef2 = new PropDef(ENUM_PROP_NAME_EMPTY, typeof(TestEnumEmpty), PropReadWriteRule.ReadWrite, null); PropDef propDef3 = new PropDef(ENUM_PROP_NAME_PASCAL, typeof(TestEnumPascalCase), PropReadWriteRule.ReadWrite, null); PrimaryKeyDef primaryKeyDef = new PrimaryKeyDef { propDefPK }; PropDefCol propDefCol = new PropDefCol { propDefPK, propDef, propDef2, propDef3 }; UIFormField uiFormField = new UIFormField(TestUtil.GetRandomString(), propDef.PropertyName, typeof(IComboBox), "EnumComboBoxMapper", "Habanero.Faces.Base", true, null, null, LayoutStyle.Label); UIFormColumn uiFormColumn = new UIFormColumn { uiFormField }; UIFormTab uiFormTab = new UIFormTab { uiFormColumn }; UIForm uiForm = new UIForm { uiFormTab }; UIDef uiDef = new UIDef("default", uiForm, null); UIDefCol uiDefCol = new UIDefCol { uiDef }; ClassDef classDef = new ClassDef(typeof(EnumBO), primaryKeyDef, propDefCol, new KeyDefCol(), null, uiDefCol); return(classDef); }
private new static ClassDef CreateClassDef() { PropDefCol lPropDefCol = new PropDefCol(); PropDef propDef = new PropDef("Radius", typeof(int), PropReadWriteRule.ReadWrite, null); lPropDefCol.Add(propDef); //propDef = new PropDef("ContactPersonID", typeof(Guid), PropReadWriteRule.WriteOnce, "ContactPersonID", null); //lPropDefCol.Add(propDef); KeyDefCol keysCol = new KeyDefCol(); RelationshipDefCol relDefCol = new RelationshipDefCol(); //RelKeyDef relKeyDef = new RelKeyDef(); //IPropDef relPropDef = lPropDefCol["ContactPersonID"]; //RelPropDef lRelPropDef = new RelPropDef(relPropDef, "ContactPersonID"); //relKeyDef.Add(lRelPropDef); //RelationshipDef relDef = new SingleRelationshipDef("ContactPerson", typeof(ContactPerson), relKeyDef, false, DeleteParentAction.DoNothing); //relDefCol.Add(relDef); ClassDef lClassDef = new ClassDef(typeof(CircleNoPrimaryKey), null, "circle_table", lPropDefCol, keysCol, relDefCol, null); //ClassDef lClassDef = new ClassDef(typeof(CircleNoPrimaryKey), null, lPropDefCol, keysCol, relDefCol); lClassDef.SuperClassDef = new SuperClassDef(Shape.GetClassDef(), ORMapping.ClassTableInheritance); ClassDef.ClassDefs.Add(lClassDef); return(lClassDef); }
/// <summary> /// Sets up the items to be listed in the ComboBox /// </summary> public override void SetupComboBoxItems() { if (_businessObject == null) { throw new InvalidOperationException("The BusinessObject must be set on the EnumComboBoxMapper before calling SetupComboBoxItems"); } _comboBox.Items.Clear(); PropDef propDef = (PropDef)_businessObject.ClassDef.PropDefcol[PropertyName]; if (!propDef.PropertyType.IsEnum) { throw new InvalidPropertyException("EnumComboBoxMapper can only be used for an enum property type"); } _comboBox.Items.Add(""); string[] names = Enum.GetNames(propDef.PropertyType); foreach (string name in names) { string spacedName = StringUtilities.DelimitPascalCase(name, " "); _comboBox.Items.Add(spacedName); } }
public void TestProtectedSets() { FakeRelationshipDef relDef = new FakeRelationshipDef(); RelKeyDef relKeyDef = new RelKeyDef(); PropDef propDef = new PropDef("prop", typeof(string), PropReadWriteRule.ReadWrite, null); relKeyDef.Add(new RelPropDef(propDef, "")); Assert.AreEqual("rel", relDef.RelationshipName); relDef.SetRelationshipName("newrel"); Assert.AreEqual("newrel", relDef.RelationshipName); Assert.AreEqual(typeof(MyRelatedBo), relDef.RelatedObjectClassType); relDef.SetRelatedObjectClassType(typeof(MyBO)); Assert.AreEqual(typeof(MyBO), relDef.RelatedObjectClassType); Assert.AreEqual("Habanero.Test", relDef.RelatedObjectAssemblyName); relDef.SetRelatedObjectAssemblyName("someassembly"); Assert.AreEqual("someassembly", relDef.RelatedObjectAssemblyName); Assert.AreEqual("Habanero.Test.MyBO", relDef.RelatedObjectClassName); relDef.SetRelatedObjectClassName("someclass"); Assert.AreEqual("someclass", relDef.RelatedObjectClassName); Assert.AreEqual(0, relDef.RelKeyDef.Count); relDef.SetRelKeyDef(relKeyDef); Assert.AreEqual(1, relDef.RelKeyDef.Count); Assert.IsTrue(relDef.KeepReferenceToRelatedObject); relDef.SetKeepReferenceToRelatedObject(false); Assert.IsFalse(relDef.KeepReferenceToRelatedObject); }
public static void updateITEMPropbyName(VDF.Vault.Currency.Connections.Connection connection, Item item, string PropName, string propValue) { try { using (WebServiceManager wServ = connection.WebServiceManager) //using will log out after usage { ItemService IS = wServ.ItemService; PropDef propDefs = getPropertyDefDetails(connection, "ITEM", PropName); var editITEM = IS.EditItems(new long[] { item.RevId })[0]; GenVaultHelper.LibNotes(); rID = new[] { editITEM.RevId }; PropInstParam PIP = new PropInstParam() { PropDefId = propDefs.Id, Val = propValue }; Item[] uitem = IS.UpdateItemProperties(rID, new PropInstParamArray[] { new PropInstParamArray() { Items = new PropInstParam[] { PIP } } }); IS.UpdateAndCommitItems(uitem); //IS.UpdateAndCommitItems(new Item[] { item }); //IS.DeleteUncommittedItems(false); } } catch (System.Exception ex) { //return ex.ToString(); } }
internal static MockBO CreateMockBOWithExtraReadOnlyProp(string newPropName) { ClassDef newClassDef = new MockBO().ClassDef.Clone(); PropDef def = new PropDef(newPropName, typeof(string), PropReadWriteRule.ReadOnly, ""); newClassDef.PropDefcol.Add(def); return(new MockBO(newClassDef)); }
internal static MockBO CreateMockBOWithExtraNonPersistableProp(string newPropName) { ClassDef newClassDef = new MockBO().ClassDef.Clone(); PropDef def = new PropDef(newPropName, typeof (string), PropReadWriteRule.ReadWrite, "") {Persistable = false}; newClassDef.PropDefcol.Add(def); return new MockBO(newClassDef); }
public void TestFixtureSetup() { ClassDef.ClassDefs.Clear(); MyBO.LoadClassDefsNoUIDef(); //Code that is executed before any test is run in this class. If multiple tests // are executed then it will still only be called once. _propDef = new PropDef("PropName", typeof (Guid), PropReadWriteRule.ReadWrite, null); }
/// <summary> /// Creates and adds a new property definition as before, but /// assumes the database field name is the same as the property name. /// </summary> internal IPropDef Add(string propName, Type propType, PropReadWriteRule propRWStatus, object defaultValue) { CheckPropNotAlreadyAdded(propName); PropDef lPropDef = new PropDef(propName, propType, propRWStatus, defaultValue); _propDefs.Add(lPropDef.PropertyName.ToUpper(), lPropDef); return(lPropDef); }
private IPropDef CreatePrimaryKeyProp() { var propertyName = PropNamingConvention.GetIDPropertyName(_classType); IPropDef propDef = new PropDef(propertyName, typeof(Guid), PropReadWriteRule.WriteNew, null); this.ClassDef.PropDefcol.Add(propDef); return(propDef); }
private static PropDef GetPropDef_WithDatabaseLookupList(out DatabaseLookupList databaseLookupList) { PropDef propDef = new PropDef("PropName", typeof(int), PropReadWriteRule.ReadWrite, null); databaseLookupList = new DatabaseLookupList(_sql); propDef.LookupList = databaseLookupList; return(propDef); }
public void SetUp() { PropDef propDef = new PropDef("Prop", typeof(string), PropReadWriteRule.ReadWrite, null); mRelPropDef = new RelPropDef(propDef, "PropName"); mPropDefCol = new PropDefCol(); mPropDefCol.Add(propDef); BORegistry.DataAccessor = new DataAccessorInMemory(); }
public static IClassDef GetClassDefWithSingleInheritanceHierarchy_NonPersistableProp(string nonPersistablePropertyName) { var filledCircleClassDef = GetClassDefWithSingleInheritanceHierarchy(); var nonPersistablePropDef = new PropDef(nonPersistablePropertyName, typeof(string), PropReadWriteRule.ReadWrite, ""); nonPersistablePropDef.Persistable = false; filledCircleClassDef.SuperClassClassDef.PropDefcol.Add(nonPersistablePropDef); return filledCircleClassDef; }
public void TestContainsPropDef() { PropDef propDef = new PropDef("prop", typeof(string), PropReadWriteRule.ReadWrite, null); PropDefColInheritor col = new PropDefColInheritor(); Assert.IsFalse(col.GetContains(propDef)); col.Add(propDef); Assert.IsTrue(col.GetContains(propDef)); }
protected static PropDefCol CreateBOPropDef() { var lPropDefCol = new PropDefCol(); var propDef = new PropDef(PK1_PROP1_NAME, typeof(string), PropReadWriteRule.ReadWrite, "PK1_Prop1", null); lPropDefCol.Add(propDef); return lPropDefCol; }
public void TestRemove() { PropDef propDef = new PropDef("prop", typeof(string), PropReadWriteRule.ReadWrite, null); PropDefColInheritor col = new PropDefColInheritor(); col.CallRemove(propDef); col.Add(propDef); Assert.AreEqual(1, col.Count); col.CallRemove(propDef); Assert.AreEqual(0, col.Count); }
private static ClassDef CreateClassDef() { PropDefCol lPropDefCol = new PropDefCol(); PropDef propDef = new PropDef("SomeNewProp", typeof(int), PropReadWriteRule.ReadWrite, null); lPropDefCol.Add(propDef); KeyDefCol keysCol = new KeyDefCol(); RelationshipDefCol relDefCol = new RelationshipDefCol(); ClassDef lClassDef = new ClassDef(typeof(BOWithIntID_Child), null, "bowithintid", lPropDefCol, keysCol, relDefCol, null); return lClassDef; }
public void Test_SetPropDefUnitOfMeasure() { //---------------Set up test pack------------------- PropDef propDef = new PropDef("PropName", typeof (string), PropReadWriteRule.ReadOnly, null); //---------------Assert Precondition---------------- Assert.AreEqual("", propDef.UnitOfMeasure); //---------------Execute Test ---------------------- const string newUOM = "New UOM"; propDef.UnitOfMeasure = newUOM; //---------------Test Result ----------------------- Assert.AreEqual(newUOM, propDef.UnitOfMeasure); }
public void SetupTest() { ClassDef.ClassDefs.Clear(); this.SetupDBConnection(); BORegistry.DataAccessor = new DataAccessorDB(); _propDef_int = new PropDef("PropName", typeof(int), PropReadWriteRule.ReadWrite, null); DatabaseLookupList databaseLookupList = new DatabaseLookupList(_sql, 10000, "", "", true); _propDef_int.LookupList = databaseLookupList; databaseLookupList.GetLookupList(); }
public void SetupTestFixture() { //Code that is executed before any test is run in this class. If multiple tests // are executed then it will still only be called once. ClassDef.ClassDefs.Clear(); this.SetupDBConnection(); BORegistry.DataAccessor = new DataAccessorDB(); _propDef_guid = new PropDef("PropName", typeof (Guid), PropReadWriteRule.ReadWrite, null); DatabaseLookupList databaseLookupList = new DatabaseLookupList(_sql) {PropDef = _propDef_guid}; databaseLookupList.GetLookupList(); _propDef_guid.LookupList = databaseLookupList; }
public void Test_SetLookupListForPropDef() { //---------------Set up test pack------------------- PropDef propDef = new PropDef("PropName", typeof (int), PropReadWriteRule.ReadWrite, null); DatabaseLookupList databaseLookupList = new DatabaseLookupList(_sql); //---------------Assert Precondition---------------- Assert.IsInstanceOf(typeof (NullLookupList), propDef.LookupList); //---------------Execute Test ---------------------- propDef.LookupList = databaseLookupList; //---------------Test Result ----------------------- Assert.IsNotNull(propDef.LookupList); Assert.AreSame(propDef, databaseLookupList.PropDef); }
private new static ClassDef CreateClassDef() { PropDefCol lPropDefCol = new PropDefCol(); PropDef propDef = new PropDef("Colour", typeof(int), PropReadWriteRule.ReadWrite, null); lPropDefCol.Add(propDef); KeyDefCol keysCol = new KeyDefCol(); RelationshipDefCol relDefCol = new RelationshipDefCol(); //ClassDef lClassDef = new ClassDef(typeof (FilledCircleNoPrimaryKey), null, lPropDefCol, keysCol, relDefCol); ClassDef lClassDef = new ClassDef(typeof(FilledCircleNoPrimaryKey), null, "FilledCircle_table", lPropDefCol, keysCol, relDefCol, null); lClassDef.SuperClassDef = new SuperClassDef(Circle.GetClassDef(), ORMapping.ConcreteTableInheritance); ClassDef.ClassDefs.Add(lClassDef); return lClassDef; }
public void TestFixtureSetup() { //Code that is executed before any test is run in this class. If multiple tests // are executed then it will still only be called once. ClassDef.ClassDefs.Clear(); BOWithIntID.LoadClassDefWithIntID(); _propDef_int = new PropDef("PropName", typeof (int), PropReadWriteRule.ReadWrite, null); _validBusinessObject = new BOWithIntID {TestField = _validLookupValue}; _validIntID = 3; _validBusinessObject.IntID = _validIntID; _collection_IntId = new BusinessObjectCollection<BOWithIntID> {_validBusinessObject}; _propDef_int.LookupList = new BusinessObjectLookupListStub(typeof (BOWithIntID), _collection_IntId); }
public void Setup() { ClassDef.ClassDefs.Clear(); FixtureEnvironment.SetupInMemoryDataAccessor(); FixtureEnvironment.SetupNewIsolatedBusinessObjectManager(); MyBO.LoadClassDefsNoUIDef(); _propDefGuid = new PropDef("PropName", typeof(Guid), PropReadWriteRule.ReadWrite, null); _validBusinessObject = new MyBO { TestProp = "ValidValue" }; _collection = new BusinessObjectCollection<MyBO> { _validBusinessObject }; _validLookupValue = _validBusinessObject.ToString(); _propDefGuid.LookupList = new BusinessObjectLookupListStub(typeof(MyBO), _collection); _validBusinessObjectNotInList = new MyBO { TestProp = "AnotherValue" }; ClassDef.ClassDefs.Clear(); }
public void TestCreateRelPropNotNull() { PropDef propDef = new PropDef("Prop1", typeof(string), PropReadWriteRule.ReadWrite, "1"); RelPropDef relPropDef = new RelPropDef(propDef, "PropName1"); PropDefCol propDefCol = new PropDefCol(); propDefCol.Add(propDef); IBOPropCol propCol = propDefCol.CreateBOPropertyCol(true); IRelProp relProp = relPropDef.CreateRelProp(propCol); Assert.AreEqual(relPropDef.OwnerPropertyName, relProp.OwnerPropertyName); Assert.AreEqual(relPropDef.RelatedClassPropName, relProp.RelatedClassPropName); Assert.IsFalse(relProp.IsNull); }
public void Test_ConstructBOPropWithValue() { //---------------Set up test pack------------------- PropDef propDef = new PropDef("Name", typeof(string), PropReadWriteRule.WriteNotNew, "DD", "", false, false); const string value = "value"; //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- BOProp prop1 = new BOProp(propDef, value); //---------------Test Result ----------------------- Assert.IsTrue(prop1.IsObjectNew); Assert.AreEqual(value, prop1.Value); Assert.AreEqual(value, prop1.PropertyValueToDisplay); }
public void Test_PropertyType_WhenTypeNotNullable_ShouldRetType() { //---------------Set up test pack------------------- Type propType = typeof (Guid); IPropDef propDef = new PropDef("PropName", propType, PropReadWriteRule.ReadOnly, null); //---------------Assert Precondition---------------- Assert.IsNotEmpty(propDef.PropertyTypeName); Assert.IsNotNull(propDef.PropertyType); Assert.IsFalse(ReflectionUtilities.IsNullableType(propType)); Assert.AreSame(typeof(Guid), ReflectionUtilities.GetNullableUnderlyingType(propType)); //---------------Execute Test ---------------------- Type propertyType = propDef.PropertyType; //---------------Test Result ----------------------- Assert.AreSame(typeof(Guid), propertyType); }
public void Test_GetKey_FromLookupList() { //---------------Set up test pack------------------- PropDef propDef = new PropDef("PropName", typeof (Guid), PropReadWriteRule.ReadWrite, null); DatabaseLookupList databaseLookupList = new DatabaseLookupList(_sql); propDef.LookupList = databaseLookupList; //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- Dictionary<string, string> lookupList = databaseLookupList.GetLookupList(); //---------------Test Result ----------------------- Assert.AreEqual(2, lookupList.Count, "There should be two item in the lookup list"); Assert.IsTrue(lookupList.ContainsKey(_validLookupValue)); string objectIDAsString = lookupList[_validLookupValue]; Assert.AreEqual(_validID.ToString(), objectIDAsString); }
public void Test_CreatePrimaryKey_TwoPropDefs() { //---------------Set up test pack------------------- PropDef propDef1 = new PropDef("prop1", typeof(String), PropReadWriteRule.ReadWrite, null); PropDef propDef2 = new PropDef("prop2", typeof(String), PropReadWriteRule.ReadWrite, null); PrimaryKeyDef keyDef = new PrimaryKeyDef { IsGuidObjectID = false }; keyDef.Add(propDef2); keyDef.Add(propDef1); //---------------Assert Precondition---------------- Assert.AreEqual(2, keyDef.Count); //---------------Execute Test ---------------------- bool isCompositeKey = keyDef.IsCompositeKey; //---------------Test Result ----------------------- Assert.IsTrue(isCompositeKey); }
public void Test_ValidateProp_WhenPropNotValid_IsValidFalse() { //---------------Set up test pack------------------- //Test compulsory with no default set PropDef lPropDefWithRules = new PropDef("PropNameWithRules", "System", "String", PropReadWriteRule.ReadWrite, null, null, true, false); lPropDefWithRules.AddPropRule(new PropRuleString(lPropDefWithRules.PropertyName, "", -1, -1, null)); IBOProp lBOProp = lPropDefWithRules.CreateBOProp(true); //---------------Assert Precondition---------------- Assert.IsTrue(lBOProp.IsValid); Assert.AreEqual("", lBOProp.InvalidReason); //---------------Execute Test ---------------------- lBOProp.Validate(); //---------------Test Result ----------------------- Assert.IsFalse(lBOProp.IsValid); StringAssert.Contains("'Prop Name With Rules' is a compulsory field and has no value.", lBOProp.InvalidReason); }
public void TestMultiplePropertiesForIDException() { //---------------Set up test pack------------------- PropDef propDef1 = new PropDef("prop1", typeof(String), PropReadWriteRule.ReadWrite, null); PropDef propDef2 = new PropDef("prop2", typeof(String), PropReadWriteRule.ReadWrite, null); //---------------Execute Test ---------------------- try { new PrimaryKeyDef {propDef1, propDef2}; Assert.Fail("Expected to throw an InvalidPropertyException"); } //---------------Test Result ----------------------- catch (InvalidPropertyException ex) { StringAssert.Contains("You cannot have more than one property for a primary key that represents an object's Guid ID", ex.Message); } }