/// <summary> /// Test which should be called for all settable properties, /// in order to verify functionality of IAccess methods. /// </summary> /// <param name="propertyId">property ID of settable property</param> public virtual void SettablePropertiesTest(ModelCode propertyId) { Assert.IsTrue(entity.HasProperty(propertyId)); Property initialValue = generator.Generate(propertyId); Assert.NotNull(initialValue); entity.SetProperty(initialValue); Property currentValue = entity.GetProperty(propertyId); Assert.AreEqual(initialValue, currentValue); }
/// <summary> /// Returns related gids with source according to the association /// </summary> /// <param name="source">source id</param> /// <param name="association">desinition of association</param> /// <returns>related gids</returns> private List <long> ApplyAssocioationOnSource(long source, Association association) { List <long> relatedGids = new List <long>(); if (association == null) { association = new Association(); } lock (SmartContainer.Instance.Lock2PC) { IdentifiedObject io = smartContainer.GetEntity(smartContainer.Original, source); if (!io.HasProperty(association.PropertyId)) { throw new Exception(string.Format("Entity with GID = 0x{0:x16} does not contain prperty with Id = {1}.", source, association.PropertyId)); } Property propertyRef = null; if (Property.GetPropertyType(association.PropertyId) == PropertyType.Reference) { propertyRef = io.GetProperty(association.PropertyId); long relatedGidFromProperty = propertyRef.AsReference(); if (relatedGidFromProperty != 0) { if (association.Type == 0 || (short)ModelCodeHelper.GetTypeFromModelCode(association.Type) == ModelCodeHelper.ExtractTypeFromGlobalId(relatedGidFromProperty)) { relatedGids.Add(relatedGidFromProperty); } } } else if (Property.GetPropertyType(association.PropertyId) == PropertyType.ReferenceVector) { propertyRef = io.GetProperty(association.PropertyId); List <long> relatedGidsFromProperty = propertyRef.AsReferences(); if (relatedGidsFromProperty != null) { foreach (long relatedGidFromProperty in relatedGidsFromProperty) { if (association.Type == 0 || (short)ModelCodeHelper.GetTypeFromModelCode(association.Type) == ModelCodeHelper.ExtractTypeFromGlobalId(relatedGidFromProperty)) { relatedGids.Add(relatedGidFromProperty); } } } } else { throw new Exception(string.Format("Association propertyId = {0} is not reference or reference vector type.", association.PropertyId)); } } return(relatedGids); }