Exemple #1
0
        public void EdmStructuralTypeInfo_IsNavigationPropertyDefined_ReturnsCorrectBoolean()
        {
            // Assert
            var structuralTypeInfo = new SelectExpandNode.EdmStructuralTypeInfo(_model.Model, _model.Customer);

            IEdmNavigationProperty property      = _model.Customer.DeclaredNavigationProperties().FirstOrDefault();
            IEdmNavigationProperty orderProperty = _model.Order.DeclaredNavigationProperties().FirstOrDefault();

            // Act & Assert
            Assert.True(structuralTypeInfo.IsNavigationPropertyDefined(property));
            Assert.False(structuralTypeInfo.IsNavigationPropertyDefined(orderProperty));
        }
Exemple #2
0
        public void EdmStructuralTypeInfo_ReturnsNullForEmptyStructuredType()
        {
            // Assert
            EdmModel      model  = new EdmModel();
            EdmEntityType entity = new EdmEntityType("NS", "Entity");

            model.AddElement(entity);

            // Act
            var structuralTypeInfo = new SelectExpandNode.EdmStructuralTypeInfo(model, entity);

            // Assert
            Assert.Null(structuralTypeInfo.AllStructuralProperties);
            Assert.Null(structuralTypeInfo.AllNavigationProperties);

            Assert.Null(structuralTypeInfo.AllActions);
            Assert.Null(structuralTypeInfo.AllFunctions);
        }
Exemple #3
0
        public void EdmStructuralTypeInfoCtor_ReturnsCorrectProperties(string typeName, int structurals, int navigations, int actions, int functions)
        {
            // Assert
            IEdmStructuredType structuralType = _model.Model.SchemaElements.OfType <IEdmSchemaType>().FirstOrDefault(c => c.Name == typeName) as IEdmStructuredType;

            Assert.NotNull(structuralType); // Guard

            // Act
            var structuralTypeInfo = new SelectExpandNode.EdmStructuralTypeInfo(_model.Model, structuralType);

            // Assert
            Assert.NotNull(structuralTypeInfo.AllStructuralProperties);
            Assert.Equal(structurals, structuralTypeInfo.AllStructuralProperties.Count);

            if (navigations == 0)
            {
                Assert.Null(structuralTypeInfo.AllNavigationProperties);
            }
            else
            {
                Assert.NotNull(structuralTypeInfo.AllNavigationProperties);
                Assert.Equal(navigations, structuralTypeInfo.AllNavigationProperties.Count);
            }

            if (actions == 0)
            {
                Assert.Null(structuralTypeInfo.AllActions);
            }
            else
            {
                Assert.NotNull(structuralTypeInfo.AllActions);
                Assert.Equal(actions, structuralTypeInfo.AllActions.Count);
            }

            if (functions == 0)
            {
                Assert.Null(structuralTypeInfo.AllFunctions);
            }
            else
            {
                Assert.NotNull(structuralTypeInfo.AllFunctions);
                Assert.Equal(functions, structuralTypeInfo.AllFunctions.Count);
            }
        }