public void EdmPropertyConstructor() { var e = new EdmPropertyConstructor("n1", new EdmStringConstant("qwerty")); Assert.AreEqual("n1", e.Name, "e.Name"); Assert.AreEqual("qwerty", ((IEdmStringValue)e.Value).Value, ((IEdmStringValue)e.Value).Value); Assert.IsFalse(e.IsBad(), "e good"); try { new EdmPropertyConstructor(null, new EdmStringConstant("qwerty")); Assert.Fail("exception expected"); } catch (ArgumentNullException) { } try { new EdmPropertyConstructor("n1", null); Assert.Fail("exception expected"); } catch (ArgumentNullException) { } var ee = new MutablePropertyConstructor(); Assert.IsNull(ee.Name, "ee.Name"); Assert.IsNull(ee.Value, "ee.Expression"); Assert.IsTrue(ee.IsBad(), "Expression is bad."); Assert.AreEqual(2, ee.Errors().Count(), "Expression has errors"); }
public static IEdmPropertyConstructor CreatePermissionProperty(params string[] scopeNames) { var scopes = scopeNames.Select(scope => new EdmRecordExpression( new EdmPropertyConstructor("Scope", new EdmStringConstant(scope)), new EdmPropertyConstructor("RestrictedProperties", new EdmStringConstant("*")))); var permission = new EdmRecordExpression( new EdmPropertyConstructor("SchemeName", new EdmStringConstant("AuthScheme")), new EdmPropertyConstructor("Scopes", new EdmCollectionExpression(scopes))); var property = new EdmPropertyConstructor("Permissions", new EdmCollectionExpression(permission)); return(property); }
internal override void WriteOperationParameterEndElement(IEdmOperationParameter parameter) { IEdmOptionalParameter optionalParameter = parameter as IEdmOptionalParameter; if (optionalParameter != null && !(optionalParameter.VocabularyAnnotations(this.Model).Any(a => a.Term == CoreVocabularyModel.OptionalParameterTerm))) { string defaultValue = optionalParameter.DefaultValueString; EdmRecordExpression optionalValue = new EdmRecordExpression(); this.WriteVocabularyAnnotationElementHeader(new EdmVocabularyAnnotation(parameter, CoreVocabularyModel.OptionalParameterTerm, optionalValue), false); if (!String.IsNullOrEmpty(defaultValue)) { EdmPropertyConstructor property = new EdmPropertyConstructor(CsdlConstants.Attribute_DefaultValue, new EdmStringConstant(defaultValue)); this.WriteRecordExpressionElementHeader(optionalValue); this.WritePropertyValueElementHeader(property, true); this.WriteEndElement(); this.WriteEndElement(); } this.WriteEndElement(); } this.WriteEndElement(); }