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 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 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 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 CsdlSemanticsActionImport(CsdlSemanticsEntityContainer container, CsdlActionImport actionImport, IEdmAction backingAction)
     : base(container, actionImport, backingAction)
 {
 }