public void TestElementInterfaceCriticalEntityTypeBaseType()
        {
            var expectedErrors = new EdmLibTestErrors()
            {
                { null, null, EdmErrorCode.InterfaceCriticalNavigationPartnerInvalid }
            };

            var baseEntity  = new EdmEntityType("DefaultNamespace", "baseEntity");
            var entity2     = new EdmEntityType("DefaultNamespace", "Entity2");
            var navProperty = new StubEdmNavigationProperty("Nav")
            {
                DeclaringType = baseEntity,
                Type          = new EdmEntityTypeReference(entity2, false)
            };

            navProperty.Partner = navProperty;
            baseEntity.AddProperty(navProperty);

            this.ValidateElement(baseEntity, expectedErrors);

            var entity = new EdmEntityType("DefaultNamespace", "Entity1", baseEntity);

            expectedErrors = new EdmLibTestErrors();
            this.ValidateElement(entity, expectedErrors);
        }
        public void TestElementInterfaceCriticalPropertyValueMustNotBeNull()
        {
            var expectedErrors = new EdmLibTestErrors()
            {
                { null, null, EdmErrorCode.InterfaceCriticalPropertyValueMustNotBeNull }
            };

            var baseEntity  = new EdmEntityType("DefaultNamespace", "BaseEntity");
            var navProperty = new StubEdmNavigationProperty("Nav")
            {
                DeclaringType = baseEntity,
                Partner       = new StubEdmNavigationProperty("Partner")
                {
                    DeclaringType = baseEntity, Type = new EdmEntityTypeReference(baseEntity, false)
                }
            };

            baseEntity.AddProperty(navProperty);

            this.ValidateElement(navProperty, expectedErrors);
            this.ValidateElement(baseEntity, expectedErrors);

            expectedErrors = new EdmLibTestErrors();
            var entity = new EdmEntityType("DefaultNamespace", "Entity", baseEntity);

            this.ValidateElement(entity, expectedErrors);
        }
        public static IEdmModel AllInterfaceCriticalModel()
        {
            var model     = new EdmModel();
            var valueTerm = new EdmTerm("DefaultNamespace", "Note", EdmCoreModel.Instance.GetString(true));

            model.AddElement(valueTerm);

            var badString = new CustomStringConstant("foo", EdmExpressionKind.None, EdmValueKind.Integer);

            var valueAnnotation = new EdmAnnotation(
                valueTerm,
                valueTerm,
                badString);

            model.AddVocabularyAnnotation(valueAnnotation);

            var mutableValueAnnotationueAnnotation = new MutableValueAnnotation()
            {
                Target = valueTerm
            };

            model.AddVocabularyAnnotation(mutableValueAnnotationueAnnotation);

            var customEntity = new CustomEntityType(new List <IEdmProperty>()
            {
                null
            });

            model.AddElement(customEntity);

            var entity      = new EdmEntityType("DefaultNamespace", "bar");
            var entity2     = new EdmEntityType("DefaultNamespace", "bar2");
            var navProperty = new StubEdmNavigationProperty("Nav")
            {
                DeclaringType = entity,
                Type          = new EdmEntityTypeReference(entity2, false)
            };

            navProperty.Partner = navProperty;
            entity.AddProperty(navProperty);
            model.AddElement(entity);
            model.AddElement(entity2);

            return(model);
        }
        public void TestManytoManyRelationshipWithOneNavigiationPropertyInOneOfThem()
        {
            var expectedErrors = new EdmLibTestErrors()
            {
                { null, null, EdmErrorCode.InterfaceCriticalNavigationPartnerInvalid }
            };

            var entity1 = new EdmEntityType("DefaultNamespace", "Entity1");
            var entity2 = new EdmEntityType("DefaultNamespace", "Entity2");

            var navProperty1 = new StubEdmNavigationProperty("Nav1")
            {
                DeclaringType = entity1,
                Type          = new EdmEntityTypeReference(entity2, false),
            };

            var navProperty2 = new StubEdmNavigationProperty("Nav2")
            {
                DeclaringType = entity1,
                Type          = new EdmEntityTypeReference(entity2, false),
            };

            var navProperty3 = new StubEdmNavigationProperty("Nav3")
            {
                DeclaringType = entity2,
                Type          = new EdmEntityTypeReference(entity1, false),
            };

            navProperty1.Partner = navProperty3;
            navProperty2.Partner = navProperty3;
            navProperty3.Partner = navProperty1;

            entity1.AddProperty(navProperty1);
            entity1.AddProperty(navProperty2);
            entity2.AddProperty(navProperty3);

            var model = new EdmModel();

            model.AddElement(entity1);
            model.AddElement(entity2);

            this.ValidateUsingEdmValidator(model, expectedErrors);
        }