Example #1
0
        public override TestResult Execute(int paramSetId)
        {
            try
            {
                NameValueCollection param = new NameValueCollection();
                _unitTestVm.ReadParameterValue(paramSetId, "RESOURCEID", param);
                _unitTestVm.ReadParameterValue(paramSetId, "CLASSNAME", param);
                _unitTestVm.ReadParameterValue(paramSetId, "PROPERTIES", param);
                _unitTestVm.ReadParameterValue(paramSetId, "FILTER", param);

                MgResourceIdentifier resId = null;
                if (param["RESOURCEID"] != null)
                {
                    resId = new MgResourceIdentifier(param["RESOURCEID"]);
                }

                MgFeatureQueryOptions query = new MgFeatureQueryOptions();
                //TODO: Set query options
                if (param["FILTER"] != null)
                {
                    query.SetFilter(param["FILTER"]);
                }

                //PROPERTIES should be stored in the database as comma separated string without spaces
                if (param["PROPERTIES"] != null)
                {
                    string [] props = param["PROPERTIES"].Split(',');
                    foreach (var p in props)
                    {
                        query.AddFeatureProperty(p);
                    }
                }

                MgFeatureReader reader     = _featureService.SelectFeatures(resId, param["CLASSNAME"], query);
                MgByteReader    byteReader = reader.ToXml();
                reader.Close();
                return(TestResult.FromByteReader(byteReader));
            }
            catch (MgException ex)
            {
                return(TestResult.FromMgException(ex));
            }
            catch (Exception ex)
            {
                return(TestResult.FromException(ex));
            }
        }
Example #2
0
 public void FillValues(MgFeatureReader reader)
 {
     List<string> toDelete = new List<string>();
     try
     {
         this.FeatId = reader.GetInt32(this._identityFieldName);
         this.UID = reader.GetInt32(this._uidKey);
         this.HaveUID = true;
     }
     catch
     {
     }
     foreach (KeyValuePair<string, FeatureProperty> item in this.Properties)
     {
         try
         {
             item.Value.Value = this._helper.GetFeaturePropertyValue(reader, item.Key, false);
             item.Value.PropertyType = reader.GetPropertyType(item.Key);
             item.Value._initialized = true;
         }
         catch (MgObjectNotFoundException)
         {
             toDelete.Add(item.Key);
         }
     }
     foreach (string key in toDelete)
     {
         this.Properties.Remove(key);
     }
     try
     {
         this.GetAviableValues(reader.ToXml().ToString());
     }
     catch
     {
     }
 }