Пример #1
0
 public void ValidationShouldFailIfAConstraintOnANonExistentReferencedPropertyIsFound()
 {
     this.ValidateReferentialConstraintWithExpectedErrors(
         @"<ReferentialConstraint Property=""ForeignKeyId1"" ReferencedProperty=""NonExistent"" />",
         EdmErrorCode.BadUnresolvedProperty,
         ErrorStrings.Bad_UnresolvedProperty("NonExistent"));
 }
Пример #2
0
 public void ParsingShouldFailIfABindingIsMissingPath()
 {
     this.ParseBindingWithExpectedErrors(
         @"<NavigationPropertyBinding Target=""EntitySet"" />",
         EdmErrorCode.MissingAttribute,
         ErrorStrings.XmlParser_MissingAttribute("Path", "NavigationPropertyBinding"));
 }
Пример #3
0
 public void ParsingShouldFailIfAConstraintIsMissingReferencedProperty()
 {
     this.ParseReferentialConstraintWithExpectedErrors(
         @"<ReferentialConstraint Property=""ForeignKeyId1"" />",
         EdmErrorCode.MissingAttribute,
         ErrorStrings.XmlParser_MissingAttribute("ReferencedProperty", "ReferentialConstraint"));
 }
Пример #4
0
 public void ValidationShouldFailIfATypeCastIsFollowedByANonExistentProperty()
 {
     this.ValidateBindingWithExpectedErrors(
         @"<NavigationPropertyBinding Path=""Test.DerivedEntityType/NonExistent"" Target=""EntitySet"" />",
         EdmErrorCode.BadUnresolvedNavigationPropertyPath,
         ErrorStrings.Bad_UnresolvedNavigationPropertyPath("Test.DerivedEntityType/NonExistent", "Test.EntityType"));
 }
Пример #5
0
 public void ValidationShouldFailIfADerivedPropertyIsUsedWithoutATypeCast()
 {
     this.ValidateBindingWithExpectedErrors(
         @"<NavigationPropertyBinding Path=""DerivedNavigation"" Target=""EntitySet"" />",
         EdmErrorCode.BadUnresolvedNavigationPropertyPath,
         ErrorStrings.Bad_UnresolvedNavigationPropertyPath("DerivedNavigation", "Test.EntityType"));
 }
Пример #6
0
 public void ValidationShouldFailIfAContainerQualifiedNameIsUsedForTheTargetOfABinding()
 {
     this.ValidateBindingWithExpectedErrors(
         @"<NavigationPropertyBinding Path=""Navigation"" Target=""Container.EntitySet"" />",
         EdmErrorCode.BadUnresolvedEntitySet,
         ErrorStrings.Bad_UnresolvedEntitySet("Container.EntitySet"));
 }
Пример #7
0
 public void ValidationShouldFailIfABindingToANonExistentSetIsFound()
 {
     this.ValidateBindingWithExpectedErrors(
         @"<NavigationPropertyBinding Path=""Navigation"" Target=""NonExistent"" />",
         EdmErrorCode.BadUnresolvedEntitySet,
         ErrorStrings.Bad_UnresolvedEntitySet("NonExistent"));
 }
Пример #8
0
 public void ParsingShouldFailIfANavigationIsMissingType()
 {
     this.ParseNavigationExpectedErrors(
         @"<NavigationProperty Name=""Navigation"" />",
         EdmErrorCode.MissingAttribute,
         ErrorStrings.XmlParser_MissingAttribute("Type", "NavigationProperty"));
 }
Пример #9
0
 public void ParsingShouldFailIfABindingHasExtraAttributes()
 {
     this.ParseBindingWithExpectedErrors(
         @"<NavigationPropertyBinding Path=""Navigation"" Target=""EntitySet"" Something=""else"" Foo=""bar"" />",
         EdmErrorCode.UnexpectedXmlAttribute,
         ErrorStrings.XmlParser_UnexpectedAttribute("Something"),
         ErrorStrings.XmlParser_UnexpectedAttribute("Foo"));
 }
Пример #10
0
 public void ParsingShouldFailIfANavigationHasAnInvalidOnDeleteAction()
 {
     this.ParseNavigationExpectedErrors(
         @"<NavigationProperty Name=""Navigation"" Type=""Test.EntityType"">
             <OnDelete Action=""Foo"" />
           </NavigationProperty>",
         EdmErrorCode.InvalidOnDelete,
         ErrorStrings.CsdlParser_InvalidDeleteAction("Foo"));
 }
Пример #11
0
 public void ParsingShouldFailIfAConstraintHasExtraAttributes()
 {
     this.ParseReferentialConstraintWithExpectedErrors(
         @"
       <ReferentialConstraint Property=""ForeignKeyId1"" ReferencedProperty=""ID1"" Something=""else"" Foo=""bar"" />",
         EdmErrorCode.UnexpectedXmlAttribute,
         ErrorStrings.XmlParser_UnexpectedAttribute("Something"),
         ErrorStrings.XmlParser_UnexpectedAttribute("Foo"));
 }
Пример #12
0
 public void ParsingShouldFailIfANavigationHasMultipleOnDeleteElements()
 {
     this.ParseNavigationExpectedErrors(
         @"<NavigationProperty Name=""Navigation"" Type=""Test.EntityType"">
             <OnDelete Action=""Cascade"" />
             <OnDelete Action=""None"" />
           </NavigationProperty>",
         EdmErrorCode.UnexpectedXmlElement,
         ErrorStrings.XmlParser_UnusedElement("OnDelete"));
 }
Пример #13
0
        public void ParsingShouldFailIfAConstraintHasAnnotations()
        {
            const string invalidConstraint = @"
              <ReferentialConstraint Property=""ForeignKeyId1"" ReferencedProperty=""ID1"">
                <Annotation Term=""FQ.NS.Term""/>
              </ReferentialConstraint>";

            this.ParseReferentialConstraintWithExpectedErrors(
                invalidConstraint,
                EdmErrorCode.UnexpectedXmlElement,
                ErrorStrings.XmlParser_UnexpectedElement("Annotation"));
        }
Пример #14
0
        public void ParsingShouldFailIfABindingHasAnnotations()
        {
            const string invalidBinding = @"
              <NavigationPropertyBinding Path=""Navigation"" Target=""EntitySet"">
                <Annotation Term=""FQ.NS.Term""/>
              </NavigationPropertyBinding>";

            this.ParseBindingWithExpectedErrors(
                invalidBinding,
                EdmErrorCode.UnexpectedXmlElement,
                ErrorStrings.XmlParser_UnexpectedElement("Annotation"));
        }
Пример #15
0
        public void ValidateEntitySetPathNavPropertyUnknownTypeCastShouldError()
        {
            ValidationRulesTests.OperationOperationEntitySetPathMustBeValidValidTestModel testModelContainer = new ValidationRulesTests.OperationOperationEntitySetPathMustBeValidValidTestModel();

            EdmFunction function = new EdmFunction("ns", "GetStuff", new EdmEntityTypeReference(testModelContainer.T3, false), true /*isBound*/, new EdmPathExpression("bindingEntity/Nav1/Bunk.T1Foo"), false);

            function.AddParameter("bindingEntity", new EdmEntityTypeReference(testModelContainer.T3, false));

            ValidateErrorInList(
                testModelContainer.Model,
                function,
                EdmErrorCode.InvalidPathUnknownTypeCastSegment,
                Strings.EdmModel_Validator_Semantic_InvalidEntitySetPathUnknownTypeCastSegment("EntitySetPath", "bindingEntity/Nav1/Bunk.T1Foo", "Bunk.T1Foo"));
        }
Пример #16
0
        public void EdmPathExpressionWithZeroSegmentsShouldFailWithError()
        {
            EdmFunction function = new EdmFunction("ns", "GetStuff", DefaultValidEntityTypeRef, true /*isBound*/, new EdmPathExpression(), false);

            function.AddParameter("param", EdmCoreModel.Instance.GetString(false));
            EdmModel model = new EdmModel();

            model.AddElement(function);
            ValidateError(
                model,
                function,
                EdmErrorCode.OperationWithInvalidEntitySetPathMissingCompletePath,
                Strings.EdmModel_Validator_Semantic_InvalidEntitySetPathMissingBindingParameterName("EntitySetPath"));
        }
Пример #17
0
        public void AnyNonBoundOperationWithAnEntitySetPathSpecifiedShouldFailWithError()
        {
            EdmFunction function = new EdmFunction("ns", "GetStuff", EdmCoreModel.Instance.GetString(false), false /*isBound*/, new EdmPathExpression("path1", "path2"), false);

            function.AddParameter("param", DefaultValidCollectionEntityTypeRef);
            EdmModel model = new EdmModel();

            model.AddElement(function);
            ValidateErrorInList(
                model,
                function,
                EdmErrorCode.OperationCannotHaveEntitySetPathWithUnBoundOperation,
                Strings.EdmModel_Validator_Semantic_OperationCannotHaveEntitySetPathWithUnBoundOperation(function.Name));
        }
Пример #18
0
        public void OperationWithEntitySetPathWithBindingParameterNotFoundShouldFailWithError()
        {
            EdmFunction   function   = new EdmFunction("ns", "GetStuff", DefaultValidEntityTypeRef, true /*isBound*/, new EdmPathExpression("incorrectBindingParameterName", "path2"), false);
            EdmEntityType entityType = new EdmEntityType("ns", "entityType");

            function.AddParameter("bindingParameter", new EdmEntityTypeReference(entityType, false));
            EdmModel model = new EdmModel();

            model.AddElement(function);
            ValidateErrorInList(
                model,
                function,
                EdmErrorCode.InvalidPathFirstPathParameterNotMatchingFirstParameterName,
                Strings.EdmModel_Validator_Semantic_InvalidEntitySetPathWithFirstPathParameterNotMatchingFirstParameterName("EntitySetPath", "incorrectBindingParameterName/path2", "incorrectBindingParameterName", "bindingParameter"));
        }
Пример #19
0
        public void EdmPathExpressionWithUnknownTypeCastSegmentShouldError()
        {
            EdmEntityType entityType = new EdmEntityType("ds.s", "entityType");
            EdmModel      model      = new EdmModel();

            model.AddElement(entityType);

            EdmFunction function = new EdmFunction("ns", "GetStuff", DefaultValidEntityTypeRef, true /*isBound*/, new EdmPathExpression("bindingEntity/unknown.EntityType"), false);

            function.AddParameter("bindingEntity", new EdmEntityTypeReference(entityType, false));
            model.AddElement(function);
            ValidateErrorInList(
                model,
                function,
                EdmErrorCode.InvalidPathUnknownTypeCastSegment,
                Strings.EdmModel_Validator_Semantic_InvalidEntitySetPathUnknownTypeCastSegment("EntitySetPath", "bindingEntity/unknown.EntityType", "unknown.EntityType"));
        }
Пример #20
0
        public void EdmPathExpressionWithCollectionBindingParameterNotAnEntityShouldError()
        {
            EdmComplexType complexType = new EdmComplexType("ds.s", "complexType");
            EdmModel       model       = new EdmModel();

            model.AddElement(complexType);

            EdmFunction function = new EdmFunction("ns", "GetStuff", DefaultValidEntityTypeRef, true /*isBound*/, new EdmPathExpression("collectionComplexParam/People"), false);

            function.AddParameter("collectionComplexParam", new EdmCollectionTypeReference(new EdmCollectionType(new EdmComplexTypeReference(complexType, false))));
            model.AddElement(function);
            ValidateError(
                model,
                function,
                EdmErrorCode.InvalidPathWithNonEntityBindingParameter,
                Strings.EdmModel_Validator_Semantic_InvalidEntitySetPathWithNonEntityBindingParameter("EntitySetPath", "collectionComplexParam/People", "collectionComplexParam"));
        }
Пример #21
0
        public void EdmPathExpressionWithInvalidNonInheritedTypeCastSegmentShouldError()
        {
            EdmEntityType entityType      = new EdmEntityType("ds.s", "entityType");
            EdmEntityType otherEntityType = new EdmEntityType("ds.s", "otherEntityType");
            EdmModel      model           = new EdmModel();

            model.AddElement(entityType);
            model.AddElement(otherEntityType);

            EdmFunction function = new EdmFunction("ns", "GetStuff", new EdmEntityTypeReference(entityType, true), true /*isBound*/, new EdmPathExpression("bindingEntity/ds.s.otherEntityType"), false);

            function.AddParameter("bindingEntity", new EdmEntityTypeReference(entityType, false));
            model.AddElement(function);

            ValidateErrorInList(
                model,
                function,
                EdmErrorCode.InvalidPathInvalidTypeCastSegment,
                Strings.EdmModel_Validator_Semantic_InvalidEntitySetPathInvalidTypeCastSegment("EntitySetPath", "bindingEntity/ds.s.otherEntityType", entityType.FullName(), otherEntityType.FullName()));
        }
Пример #22
0
        public void EdmPathExpressionWithInvalidComplexTypeCaseForTypeCastSegmentShouldError()
        {
            EdmEntityType  entityType  = new EdmEntityType("ds.s", "entityType");
            EdmComplexType complexType = new EdmComplexType("ds.s", "complexType");
            EdmModel       model       = new EdmModel();

            model.AddElement(entityType);
            model.AddElement(complexType);

            EdmFunction function = new EdmFunction("ns", "GetStuff", new EdmEntityTypeReference(entityType, true), true /*isBound*/, new EdmPathExpression("bindingEntity/ds.s.complexType"), false);

            function.AddParameter("bindingEntity", new EdmEntityTypeReference(entityType, false));
            model.AddElement(function);

            ValidateErrorInList(
                model,
                function,
                EdmErrorCode.InvalidPathTypeCastSegmentMustBeEntityType,
                Strings.EdmModel_Validator_Semantic_InvalidEntitySetPathTypeCastSegmentMustBeEntityType("EntitySetPath", "bindingEntity/ds.s.complexType", "ds.s.complexType"));
        }
Пример #23
0
        private void RunInvalidTest(Func <XmlReader, IEdmModel> parse)
        {
            Action parseAction = () => parse(this.invalidReader);

            parseAction.ShouldThrow <EdmParseException>().WithMessage(ErrorStrings.EdmParseException_ErrorsEncounteredInEdmx(ErrorMessage)).And.Errors.Should().OnlyContain(e => e.ToString() == ErrorMessage);
        }
Пример #24
0
 public void ValidationShouldFailIfNavigationParterIsSpecifiedButCannotBeFound()
 {
     this.ValidateNavigationWithExpectedErrors(@"<NavigationProperty Name=""Navigation"" Type=""Test.EntityType"" Partner=""Nonexistent"" />",
                                               EdmErrorCode.BadUnresolvedNavigationPropertyPath,
                                               ErrorStrings.Bad_UnresolvedNavigationPropertyPath("Nonexistent", "Test.EntityType"));
 }
Пример #25
0
 public void ValidationShouldFailIfNavigationTypeIsACollectionButElementTypeDoesNotExist()
 {
     this.ValidateNavigationWithExpectedErrors(@"<NavigationProperty Name=""Navigation"" Type=""Collection(Fake.Nonexistent)"" />",
                                               EdmErrorCode.BadUnresolvedEntityType,
                                               ErrorStrings.Bad_UnresolvedEntityType("Fake.Nonexistent"));
 }
Пример #26
0
 public void ValidationShouldFailIfNavigationTypeIsPrimitiveCollectionType()
 {
     this.ValidateNavigationWithExpectedErrors(@"<NavigationProperty Name=""Navigation"" Type=""Collection(Edm.Int32)"" />",
                                               EdmErrorCode.BadUnresolvedEntityType,
                                               ErrorStrings.Bad_UnresolvedEntityType("Edm.Int32"));
 }
Пример #27
0
 public void ParsingShouldFailIfNavigationNullableIsNotTrueOrFalse()
 {
     this.ParseNavigationExpectedErrors(@"<NavigationProperty Name=""Navigation"" Type=""Test.EntityType"" Nullable=""foo""/>",
                                        EdmErrorCode.InvalidBoolean,
                                        ErrorStrings.ValueParser_InvalidBoolean("foo"));
 }
Пример #28
0
 public void ParsingShouldFailIfNavigationTypeIsEmpty()
 {
     this.ParseNavigationExpectedErrors(@"<NavigationProperty Name=""Navigation"" Type="""" />",
                                        EdmErrorCode.InvalidTypeName,
                                        ErrorStrings.CsdlParser_InvalidTypeName(""));
 }