internal static CsdlEntityContainer EntityContainer( string name, string extends = null, CsdlEntitySet[] entitySets = default(CsdlEntitySet[]), CsdlSingleton[] singletons = default(CsdlSingleton[]), CsdlOperationImport[] operationImports = default(CsdlOperationImport[]), CsdlDocumentation documentation = null, CsdlLocation location = null) { if (entitySets == null) { entitySets = new CsdlEntitySet[] { }; } if (operationImports == null) { operationImports = new CsdlOperationImport[] { }; } if (singletons == null) { singletons = new CsdlSingleton[] { }; } return new CsdlEntityContainer( name, extends, entitySets, singletons, operationImports, documentation, location); }
internal static CsdlEntityType EntityType( string name, string baseName = null, bool isAbstract = false, bool isOpen = false, bool hasStream = false, CsdlKey csdlKey = null, CsdlProperty[] properties = default(CsdlProperty[]), CsdlNavigationProperty[] navProps = default(CsdlNavigationProperty[]), CsdlDocumentation documentation = null, CsdlLocation location = null) { if (properties == null) { properties = new CsdlProperty[] { }; } if (navProps == null) { navProps = new CsdlNavigationProperty[] { }; } return new CsdlEntityType( name, baseName, isAbstract, isOpen, hasStream, csdlKey, properties, navProps, documentation, location); }
public void TestCsdlTypeDefinitionConstructor() { var loc = new CsdlLocation(17, 4); var type = new CsdlTypeDefinition("Length", "Edm.Int32", loc); type.Location.Should().Be(loc); type.Name.Should().Be("Length"); type.UnderlyingTypeName.Should().Be("Edm.Int32"); }
public CsdlSemanticsOperationTests() { this.csdlEntityType = new CsdlEntityType("EntityType", null, false, false, false, null, Enumerable.Empty<CsdlProperty>(), Enumerable.Empty<CsdlNavigationProperty>(), null, null); var csdlSchema = CsdlBuilder.Schema("FQ.NS", csdlStructuredTypes: new[] { this.csdlEntityType }); var csdlModel = new CsdlModel(); csdlModel.AddSchema(csdlSchema); var semanticModel = new CsdlSemanticsModel(csdlModel, new EdmDirectValueAnnotationsManager(), Enumerable.Empty<IEdmModel>()); this.semanticSchema = new CsdlSemanticsSchema(semanticModel, csdlSchema); this.testLocation = new CsdlLocation(1, 3); }
private IEdmNavigationProperty ParseSingleConstraint(string property, string referencedProperty, CsdlLocation location = null) { var constraint = new CsdlReferentialConstraint(property, referencedProperty, null, location); var testSubject = new CsdlSemanticsNavigationProperty(this.semanticEntityType, new CsdlNavigationProperty("Fake", "Fake.Fake", false, "Fake", false, null, new[] { constraint }, null, null)); return testSubject; }
public void TryGetEntitySetWithBoundCsdlSemanticOperationParameterShouldReturnTrueAndHaveNoErrors() { var csdlEntityType = new CsdlEntityType("EntityType", null, false, false, false, null, Enumerable.Empty<CsdlProperty>(), Enumerable.Empty<CsdlNavigationProperty>(), null, null); var csdlSchema = CsdlBuilder.Schema("FQ.NS", csdlStructuredTypes: new[] { csdlEntityType }); var csdlModel = new CsdlModel(); csdlModel.AddSchema(csdlSchema); var semanticModel = new CsdlSemanticsModel(csdlModel, new EdmDirectValueAnnotationsManager(), Enumerable.Empty<IEdmModel>()); var semanticSchema = new CsdlSemanticsSchema(semanticModel, csdlSchema); var testLocation = new CsdlLocation(1, 3); var action = new CsdlAction( "Checkout", new CsdlOperationParameter[] { new CsdlOperationParameter("entity", new CsdlNamedTypeReference("FQ.NS.EntityType", false, testLocation), null, testLocation) }, new CsdlNamedTypeReference("Edm.String", false, testLocation), true /*isBound*/, "entity", null /*documentation*/, testLocation); var semanticAction = new CsdlSemanticsAction(semanticSchema, action); IEdmOperationParameter edmParameter; IEnumerable<IEdmNavigationProperty> navigationProperties; IEdmEntityType entityType; IEnumerable<EdmError> errors; semanticAction.TryGetRelativeEntitySetPath(semanticSchema.Model, out edmParameter, out navigationProperties, out entityType, out errors).Should().BeTrue(); edmParameter.Name.Should().Be("entity"); navigationProperties.Should().BeEmpty(); entityType.FullName().Should().Be("FQ.NS.EntityType"); errors.Should().BeEmpty(); }
internal static CsdlFunction Function( string name, CsdlOperationParameter[] parameters = default(CsdlOperationParameter[]), CsdlTypeReference typeReference = null, bool isBound = false, string entitySetPath = null, bool isComposable = false, CsdlDocumentation documentation = null, CsdlLocation location = null) { if (parameters == null) { parameters = new CsdlOperationParameter[] { }; } return new CsdlFunction( name, parameters, typeReference, isBound, entitySetPath, isComposable, documentation, location); }
internal static CsdlOperationParameter Parameter( string name, string fullTypeReferenceName, CsdlDocumentation documentation = null, CsdlLocation location = null) { return new CsdlOperationParameter(name, new CsdlNamedTypeReference(fullTypeReferenceName, true, null), documentation, location); }
internal static CsdlSchema Schema( string namespaceName, string alias = null, Version version = null, CsdlStructuredType[] csdlStructuredTypes = default(CsdlStructuredType[]), CsdlEnumType[] csdlEnumTypes = default(CsdlEnumType[]), CsdlOperation[] csdlOperations = default(CsdlOperation[]), CsdlTerm[] csdlTerms = default(CsdlTerm[]), CsdlEntityContainer[] csdlEntityContainers = default(CsdlEntityContainer[]), CsdlAnnotations[] csdlAnnotations = default(CsdlAnnotations[]), CsdlTypeDefinition[] csdlTypeDefinitions = default(CsdlTypeDefinition[]), CsdlDocumentation documentation = null, CsdlLocation location = null) { if (csdlStructuredTypes == null) { csdlStructuredTypes = new CsdlStructuredType[] { }; } if (csdlEnumTypes == null) { csdlEnumTypes = new CsdlEnumType[] { }; } if (csdlOperations == null) { csdlOperations = new CsdlOperation[] { }; } if (csdlTerms == null) { csdlTerms = new CsdlTerm[] { }; } if (csdlEntityContainers == null) { csdlEntityContainers = new CsdlEntityContainer[] { }; } if (csdlAnnotations == null) { csdlAnnotations = new CsdlAnnotations[] { }; } if (csdlTypeDefinitions == null) { csdlTypeDefinitions = new CsdlTypeDefinition[] { }; } var csdlSchema = new CsdlSchema( namespaceName, alias, version, csdlStructuredTypes, csdlEnumTypes, csdlOperations, csdlTerms, csdlEntityContainers, csdlAnnotations, csdlTypeDefinitions, documentation /*documentation*/, location /*location*/); return csdlSchema; }
public void NavigationTargetsShouldStillContainMappingsThatAreCompletelyWrong() { var location = new CsdlLocation(1, 1); var result = this.ParseSingleBinding("NonExistentPath", "NonExistentSet", location); result.Target.Should().BeAssignableTo<UnresolvedEntitySet>(); result.Target.As<UnresolvedEntitySet>().Name.Should().Be("NonExistentSet"); result.Target.Errors().Should().Contain(e => e.ErrorLocation == location && e.ErrorCode == EdmErrorCode.BadUnresolvedEntitySet); result.NavigationProperty.Should().BeAssignableTo<UnresolvedNavigationPropertyPath>(); result.NavigationProperty.As<UnresolvedNavigationPropertyPath>().Name.Should().Be("NonExistentPath"); result.NavigationProperty.Errors().Should().Contain(e => e.ErrorLocation == location && e.ErrorCode == EdmErrorCode.BadUnresolvedNavigationPropertyPath); }
private IEdmNavigationPropertyBinding ParseSingleBinding(string path, string target, CsdlLocation location = null) { var binding = new CsdlNavigationPropertyBinding(path, target, null, location); var testSubject = new CsdlSemanticsEntitySet(this.semanticContainer, new CsdlEntitySet("Fake", "FQ.NS.EntityType", new[] { binding }, null, null)); testSubject.NavigationPropertyBindings.Should().HaveCount(1); var result = testSubject.NavigationPropertyBindings.Single(); return result; }
public CsdlSemanticsOperationImportTests() { this.testLocation = new CsdlLocation(1, 3); }
public void AssertCorrectLocation(CsdlLocation location, string sourceText, string comparisonText) { string[] lines = sourceText.Split('\n'); string resultString = lines[location.LineNumber - 1].Substring(location.LinePosition - 1); Assert.IsTrue(resultString.StartsWith(comparisonText), "Expected text was not found at the given location."); }