private ISpatialReference GetSpatialReference([NotNull] Dataset dataset) { Assert.ArgumentNotNull(dataset, nameof(dataset)); IGeoDataset geoDataset = _datasetOpener.OpenDataset(dataset) as IGeoDataset; return(geoDataset?.SpatialReference); }
private static object GetValue([NotNull] TestParameterValue paramVal, [NotNull] TestParameter parameter, [NotNull] IOpenDataset datasetContext) { Assert.ArgumentNotNull(paramVal, nameof(paramVal)); Assert.ArgumentNotNull(parameter, nameof(parameter)); Assert.ArgumentNotNull(datasetContext, nameof(datasetContext)); var scalarParameterValue = paramVal as ScalarTestParameterValue; if (scalarParameterValue != null) { if (scalarParameterValue.DataType == null) { scalarParameterValue.DataType = parameter.Type; _msg.VerboseDebugFormat( "DataType of scalarParameterValue {0} needed to be initialized.", scalarParameterValue.TestParameterName); } return(scalarParameterValue.GetValue()); } var datasetParameterValue = paramVal as DatasetTestParameterValue; if (datasetParameterValue != null) { if (datasetParameterValue.DatasetValue == null && !parameter.IsConstructorParameter) { return(null); } Dataset dataset = Assert.NotNull(datasetParameterValue.DatasetValue, "dataset is null"); datasetParameterValue.DataType = parameter.Type; // TODO: Test in AO11 context and consider not running this test Assert.True(datasetContext.CanOpen(dataset), "Cannot open dataset {0} of type {1}", dataset, parameter.Type); object result = datasetContext.OpenDataset(dataset, datasetParameterValue.DataType); Assert.NotNull(result, "Dataset not found in current context: {0}", dataset.Name); return(result); } throw new ArgumentException($"Unhandled type {paramVal.GetType()}"); }
private static bool ExistsDataset([NotNull] IDdxDataset dataset, [NotNull] IOpenDataset datasetOpener) { // -> allow work context to load dataset from other database ('master') try { var aoDataset = datasetOpener.OpenDataset(dataset); return(aoDataset != null); } catch (Exception e) { _msg.VerboseDebug($"Error opening dataset {dataset.Name}", e); return(false); } }
private static IDictionary <string, string> GetTableNameReplacements( [NotNull] IEnumerable <DatasetTestParameterValue> datasetParameterValues, [NotNull] IOpenDataset datasetContext, [NotNull] string associationName, [NotNull] string relationshipClassName) { var replacements = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase); if (!string.Equals(associationName, relationshipClassName, StringComparison.OrdinalIgnoreCase)) { replacements.Add(associationName, relationshipClassName); } foreach (DatasetTestParameterValue datasetParameterValue in datasetParameterValues) { Dataset dataset = datasetParameterValue.DatasetValue; if (dataset == null) { continue; } var table = datasetContext.OpenDataset( dataset, Assert.NotNull(datasetParameterValue.DataType)) as ITable; if (table == null) { continue; } string tableName = DatasetUtils.GetName(table); if (!string.Equals(dataset.Name, tableName)) { replacements.Add(dataset.Name, tableName); } } return(replacements); }
private bool TryGetArgumentValue( [NotNull] TestParameter parameter, [NotNull] IOpenDataset datasetContext, [CanBeNull] ICollection <TableConstraint> tableConstraints, [CanBeNull] out object value) { if (Condition == null) { value = null; return(false); } var valuesForParameter = new List <object>(); var parameterValueList = new List <DatasetTestParameterValue>(); foreach (TestParameterValue parameterValue in Condition.ParameterValues) { if (!Equals(parameterValue.TestParameterName, parameter.Name)) { continue; } object valueForParameter = GetValue(parameterValue, parameter, datasetContext); valuesForParameter.Add(valueForParameter); // add value to list anyway, // correct type is checked at the end of parameterIndex Loop parameterValueList.Add(parameterValue as DatasetTestParameterValue); } if (valuesForParameter.Count == 0 && !parameter.IsConstructorParameter) { value = null; return(false); } value = GetArgumentValue(parameter, valuesForParameter); // if correct type, add to dataSetList if (tableConstraints != null && valuesForParameter.Count > 0 && valuesForParameter[0] is ITable) { foreach (DatasetTestParameterValue datasetParameterValue in parameterValueList) { Dataset dataset = Assert.NotNull(datasetParameterValue.DatasetValue, "dataset is null"); var table = (ITable)datasetContext.OpenDataset( dataset, Assert.NotNull(datasetParameterValue.DataType)); Assert.NotNull(table, "Dataset not found in current context: {0}", dataset.Name); DdxModel dataModel = dataset.Model; bool useCaseSensitiveSql = dataModel != null && ModelElementUtils.UseCaseSensitiveSql( table, dataModel.SqlCaseSensitivity); tableConstraints.Add(new TableConstraint( table, datasetParameterValue.FilterExpression, useCaseSensitiveSql)); } } return(true); }