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(); }
public void EnsureActionImportActionPropertyIsUnresolvedAction() { var actionImport = new CsdlActionImport("Action", "FQ.NS.Action", null /*entitySet*/, null /*documentation*/, testLocation); var csdlEntityContainer = CsdlBuilder.EntityContainer("Container", operationImports: new CsdlOperationImport[] { actionImport }); var schema = CsdlBuilder.Schema("FQ.NS", csdlEntityContainers: new CsdlEntityContainer[] { csdlEntityContainer }); var csdlModel = new CsdlModel(); csdlModel.AddSchema(schema); var semanticSchema = new CsdlSemanticsSchema(new CsdlSemanticsModel(csdlModel, new EdmDirectValueAnnotationsManager(), Enumerable.Empty <IEdmModel>()), schema); CsdlSemanticsEntityContainer container = new CsdlSemanticsEntityContainer(semanticSchema, csdlEntityContainer); var imports = container.OperationImports().ToList(); imports.Should().HaveCount(1); imports[0].Name.Should().Be("Action"); imports[0].Operation.GetType().Should().Be(typeof(UnresolvedAction)); var errors = imports[0].Operation.As <BadElement>().Errors.ToList(); errors.Should().HaveCount(1); errors.First().ErrorMessage.Should().Be(Strings.Bad_UnresolvedOperation("FQ.NS.Action")); imports[0].Container.Name.Should().Be("Container"); imports[0].Location().Should().Be(testLocation); imports[0].ContainerElementKind.Should().Be(EdmContainerElementKind.ActionImport); imports[0].EntitySet.Should().BeNull(); }
public void EnsureFunctionImportFunctionPropertyIsUnresolvedFunction() { var functionImport = new CsdlFunctionImport("GetStuff", "FQ.NS.GetStuff", null /*entitySet*/, true /*includeInServiceDocument*/, null /*documentation*/, testLocation); var csdlEntityContainer = CsdlBuilder.EntityContainer("Container", operationImports: new CsdlOperationImport[] { functionImport }); var schema = CsdlBuilder.Schema("FQ.NS", csdlEntityContainers: new CsdlEntityContainer[] { csdlEntityContainer }); var csdlModel = new CsdlModel(); csdlModel.AddSchema(schema); var semanticSchema = new CsdlSemanticsSchema(new CsdlSemanticsModel(csdlModel, new EdmDirectValueAnnotationsManager(), Enumerable.Empty <IEdmModel>()), schema); CsdlSemanticsEntityContainer container = new CsdlSemanticsEntityContainer(semanticSchema, csdlEntityContainer); var imports = container.OperationImports().ToList(); imports.Should().HaveCount(1); var csdlFunctionImport = (IEdmFunctionImport)imports[0]; csdlFunctionImport.Name.Should().Be("GetStuff"); csdlFunctionImport.Operation.GetType().Should().Be(typeof(UnresolvedFunction)); var errors = csdlFunctionImport.Operation.As <BadElement>().Errors.ToList(); errors.Should().HaveCount(1); errors.First().ErrorMessage.Should().Be(Strings.Bad_UnresolvedOperation("FQ.NS.GetStuff")); csdlFunctionImport.Container.Name.Should().Be("Container"); csdlFunctionImport.Location().Should().Be(testLocation); csdlFunctionImport.ContainerElementKind.Should().Be(EdmContainerElementKind.FunctionImport); csdlFunctionImport.EntitySet.Should().BeNull(); csdlFunctionImport.IncludeInServiceDocument.Should().BeTrue(); csdlFunctionImport.Function.IsComposable.Should().BeFalse(); }
private static CsdlSemanticsSchema CreateCsdlSemanticsSchema(CsdlEntityContainer csdlEntityContainer, params CsdlOperation[] operations) { var csdlEntityType = new CsdlEntityType("EntityType", null, false, false, false, null, new Collection <CsdlProperty>(), new BindingList <CsdlNavigationProperty>(), null, null); var schema = CsdlBuilder.Schema("FQ.NS", csdlOperations: operations, csdlEntityContainers: new CsdlEntityContainer[] { csdlEntityContainer }, csdlStructuredTypes: new CsdlStructuredType[] { csdlEntityType }); var csdlModel = new CsdlModel(); csdlModel.AddSchema(schema); var semanticSchema = new CsdlSemanticsSchema(new CsdlSemanticsModel(csdlModel, new EdmDirectValueAnnotationsManager(), Enumerable.Empty <IEdmModel>()), schema); return(semanticSchema); }
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); }
public void EnsureEntitySetResolvesToUnknownEntitySet() { var action = CsdlBuilder.Action("Checkout"); var actionImport = new CsdlActionImport("Checkout", "FQ.NS.Checkout", "OtherSet" /*entitySet*/, null /*documentation*/, testLocation); var csdlEntityContainer = CsdlBuilder.EntityContainer("Container"); var semanticSchema = CreateCsdlSemanticsSchema(csdlEntityContainer, action); var semanticAction = new CsdlSemanticsAction(semanticSchema, action); var csdlSemanticEntityContainer = new CsdlSemanticsEntityContainer(semanticSchema, csdlEntityContainer); var semanticActionImport = new CsdlSemanticsActionImport(csdlSemanticEntityContainer, actionImport, semanticAction); semanticActionImport.Action.Should().NotBeNull(); semanticActionImport.Action.Name.Should().Be("Checkout"); var edmEntitySetReference = (IEdmEntitySetReferenceExpression)semanticActionImport.EntitySet; edmEntitySetReference.ReferencedEntitySet.Name.Should().Be("OtherSet"); }
public void EnsureEntitySetReferenceResolvesCorrectly() { var action = CsdlBuilder.Action("Checkout"); var actionImport = new CsdlActionImport("Checkout", "FQ.NS.Checkout", "EntitySet" /*entitySet*/, null /*documentation*/, testLocation); var csdlEntitySet = new CsdlEntitySet("EntitySet", "FQ.NS.EntityType", Enumerable.Empty <CsdlNavigationPropertyBinding>(), null, testLocation); var csdlEntityContainer = CsdlBuilder.EntityContainer("Container", entitySets: new CsdlEntitySet[] { csdlEntitySet }); var semanticSchema = CreateCsdlSemanticsSchema(csdlEntityContainer, action); var semanticAction = new CsdlSemanticsAction(semanticSchema, action); var csdlSemanticEntityContainer = new CsdlSemanticsEntityContainer(semanticSchema, csdlEntityContainer); var semanticActionImport = new CsdlSemanticsActionImport(csdlSemanticEntityContainer, actionImport, semanticAction); semanticActionImport.Action.Should().NotBeNull(); semanticActionImport.Action.Name.Should().Be("Checkout"); var edmEntitySetReference = (IEdmEntitySetReferenceExpression)semanticActionImport.EntitySet; edmEntitySetReference.ReferencedEntitySet.Name.Should().Be("EntitySet"); }
public void CsdlSemanticsActionImportPropertiesShouldBeInitializedCorrectly() { var action = CsdlBuilder.Action("Checkout"); var actionImport = new CsdlActionImport("Checkout", "FQ.NS.Checkout", null, null /*documentation*/, testLocation); var csdlEntityContainer = CsdlBuilder.EntityContainer("Container"); var semanticSchema = CreateCsdlSemanticsSchema(csdlEntityContainer, action); var semanticAction = new CsdlSemanticsAction(semanticSchema, action); var csdlSemanticEntityContainer = new CsdlSemanticsEntityContainer(semanticSchema, csdlEntityContainer); var semanticActionImport = new CsdlSemanticsActionImport(csdlSemanticEntityContainer, actionImport, semanticAction); semanticActionImport.Action.Should().NotBeNull(); semanticActionImport.Action.Name.Should().Be("Checkout"); semanticActionImport.Container.Name.Should().Be("Container"); semanticActionImport.Location().Should().Be(testLocation); semanticActionImport.ContainerElementKind.Should().Be(EdmContainerElementKind.ActionImport); semanticActionImport.EntitySet.Should().BeNull(); }
public void EnsureEntitySetResolvesToEdmPathExpression() { var action = CsdlBuilder.Action("Checkout"); var actionImport = new CsdlActionImport("Checkout", "FQ.NS.Checkout", "Nav1/Nav2" /*entitySet*/, null /*documentation*/, testLocation); var csdlEntityContainer = CsdlBuilder.EntityContainer("Container"); var semanticSchema = CreateCsdlSemanticsSchema(csdlEntityContainer, action); var semanticAction = new CsdlSemanticsAction(semanticSchema, action); var csdlSemanticEntityContainer = new CsdlSemanticsEntityContainer(semanticSchema, csdlEntityContainer); var semanticActionImport = new CsdlSemanticsActionImport(csdlSemanticEntityContainer, actionImport, semanticAction); semanticActionImport.Action.Should().NotBeNull(); semanticActionImport.Action.Name.Should().Be("Checkout"); var pathExpression = (IEdmPathExpression)semanticActionImport.EntitySet; var items = pathExpression.Path.ToList(); items[0].Should().Be("Nav1"); items[1].Should().Be("Nav2"); }
public void CsdlSemanticsFunctionImportPropertiesShouldBeInitializedCorrectly() { // Added to ensure this is filtered out var function = CsdlBuilder.Function("GetStuff"); var functionImport = new CsdlFunctionImport("GetStuff", "FQ.NS.GetStuff", null /*entitySet*/, true /*includeInServiceDocument*/, null /*documentation*/, testLocation); var csdlEntityContainer = CsdlBuilder.EntityContainer("Container"); var semanticSchema = CreateCsdlSemanticsSchema(csdlEntityContainer, function); var semanticFunction = new CsdlSemanticsFunction(semanticSchema, function); var csdlSemanticEntityContainer = new CsdlSemanticsEntityContainer(semanticSchema, csdlEntityContainer); var semanticActionImport = new CsdlSemanticsFunctionImport(csdlSemanticEntityContainer, functionImport, semanticFunction); semanticActionImport.Function.Should().NotBeNull(); semanticActionImport.Function.Name.Should().Be("GetStuff"); semanticActionImport.Container.Name.Should().Be("Container"); semanticActionImport.Location().Should().Be(testLocation); semanticActionImport.ContainerElementKind.Should().Be(EdmContainerElementKind.FunctionImport); semanticActionImport.EntitySet.Should().BeNull(); semanticActionImport.IncludeInServiceDocument.Should().BeTrue(); }