public CsdlSemanticsEntitySetTests()
        {
            var referentialConstraints = new List<CsdlReferentialConstraint>();
            var csdlNavigation = new CsdlNavigationProperty("Navigation", null, null, null, false, null, referentialConstraints, null, null);
            this.csdlEntityType = new CsdlEntityType("EntityType", null, false, false, false, null, Enumerable.Empty<CsdlProperty>(), new[] { csdlNavigation }, null, null);
            var goodBinding = new CsdlNavigationPropertyBinding("Navigation", "EntitySet", null, new CsdlLocation(1, 1));
            this.csdlEntitySet = new CsdlEntitySet("EntitySet", "FQ.NS.EntityType", new[] { goodBinding }, null, null);
            this.csdlContainer = new CsdlEntityContainer("Container", null, new[] { this.csdlEntitySet }, Enumerable.Empty<CsdlSingleton>(), Enumerable.Empty<CsdlOperationImport>(), null, null);

            var derivedCsdlNavigation = new CsdlNavigationProperty("DerivedNavigation", null, null, null, false, null, referentialConstraints, null, null);
            var derivedCsdlEntityType = new CsdlEntityType("DerivedEntityType", "FQ.NS.EntityType", false, false, false, null, Enumerable.Empty<CsdlProperty>(), new[] { derivedCsdlNavigation }, null, null);

            var unrelatedCsdlEntityType = new CsdlEntityType("UnrelatedEntityType", null, false, false, false, null, Enumerable.Empty<CsdlProperty>(), Enumerable.Empty<CsdlNavigationProperty>(), null, null);

            var csdlSchema = new CsdlSchema("FQ.NS", null, null, new[] { this.csdlEntityType, derivedCsdlEntityType, unrelatedCsdlEntityType }, Enumerable.Empty<CsdlEnumType>(), Enumerable.Empty<CsdlOperation>(),Enumerable.Empty<CsdlTerm>(),Enumerable.Empty<CsdlEntityContainer>(),Enumerable.Empty<CsdlAnnotations>(), Enumerable.Empty<CsdlTypeDefinition>(), null, null);
            var csdlModel = new CsdlModel();
            csdlModel.AddSchema(csdlSchema);
            var semanticModel = new CsdlSemanticsModel(csdlModel, new EdmDirectValueAnnotationsManager(), Enumerable.Empty<IEdmModel>());
            this.semanticSchema = new CsdlSemanticsSchema(semanticModel, csdlSchema);
            this.semanticContainer = new CsdlSemanticsEntityContainer(this.semanticSchema, this.csdlContainer);

            this.semanticEntityType = semanticModel.FindType("FQ.NS.EntityType") as CsdlSemanticsEntityTypeDefinition;
            this.semanticEntityType.Should().NotBeNull();
            this.navigationProperty = this.semanticEntityType.FindProperty("Navigation") as CsdlSemanticsNavigationProperty;
            this.navigationProperty.Should().NotBeNull();
        }
Beispiel #2
0
        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);
        }
        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 CsdlSemanticsEntitySet(CsdlSemanticsEntityContainer container, CsdlEntitySet entitySet)
     : base(container, entitySet)
 {
 }