public void ParsingShouldFailIfABindingIsMissingPath()
 {
     this.ParseBindingWithExpectedErrors(
         @"<NavigationPropertyBinding Target=""EntitySet"" />",
         EdmErrorCode.MissingAttribute,
         ErrorStrings.XmlParser_MissingAttribute("Path", "NavigationPropertyBinding"));
 }
 public void ParsingShouldFailIfAConstraintIsMissingReferencedProperty()
 {
     this.ParseReferentialConstraintWithExpectedErrors(
         @"<ReferentialConstraint Property=""ForeignKeyId1"" />",
         EdmErrorCode.MissingAttribute,
         ErrorStrings.XmlParser_MissingAttribute("ReferencedProperty", "ReferentialConstraint"));
 }
 public void ValidationShouldFailIfADerivedPropertyIsUsedWithoutATypeCast()
 {
     this.ValidateBindingWithExpectedErrors(
         @"<NavigationPropertyBinding Path=""DerivedNavigation"" Target=""EntitySet"" />",
         EdmErrorCode.BadUnresolvedNavigationPropertyPath,
         ErrorStrings.Bad_UnresolvedNavigationPropertyPath("DerivedNavigation", "Test.EntityType"));
 }
Beispiel #4
0
 public void ValidationShouldFailIfAConstraintOnANonExistentReferencedPropertyIsFound()
 {
     this.ValidateReferentialConstraintWithExpectedErrors(
         @"<ReferentialConstraint Property=""ForeignKeyId1"" ReferencedProperty=""NonExistent"" />",
         EdmErrorCode.BadUnresolvedProperty,
         ErrorStrings.Bad_UnresolvedProperty("NonExistent"));
 }
 public void ValidationShouldFailIfATypeCastIsFollowedByANonExistentProperty()
 {
     this.ValidateBindingWithExpectedErrors(
         @"<NavigationPropertyBinding Path=""Test.DerivedEntityType/NonExistent"" Target=""EntitySet"" />",
         EdmErrorCode.BadUnresolvedNavigationPropertyPath,
         ErrorStrings.Bad_UnresolvedNavigationPropertyPath("Test.DerivedEntityType/NonExistent", "Test.EntityType"));
 }
 public void ValidationShouldFailIfABindingToANonExistentSetIsFound()
 {
     this.ValidateBindingWithExpectedErrors(
         @"<NavigationPropertyBinding Path=""Navigation"" Target=""NonExistent"" />",
         EdmErrorCode.BadUnresolvedEntitySet,
         ErrorStrings.Bad_UnresolvedEntitySet("NonExistent"));
 }
 public void ValidationShouldFailIfAContainerQualifiedNameIsUsedForTheTargetOfABinding()
 {
     this.ValidateBindingWithExpectedErrors(
         @"<NavigationPropertyBinding Path=""Navigation"" Target=""Container.EntitySet"" />",
         EdmErrorCode.BadUnresolvedEntitySet,
         ErrorStrings.Bad_UnresolvedEntitySet("Container.EntitySet"));
 }
Beispiel #8
0
 public void ParsingShouldFailIfANavigationIsMissingType()
 {
     this.ParseNavigationExpectedErrors(
         @"<NavigationProperty Name=""Navigation"" />",
         EdmErrorCode.MissingAttribute,
         ErrorStrings.XmlParser_MissingAttribute("Type", "NavigationProperty"));
 }
Beispiel #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"));
 }
Beispiel #10
0
 public void ParsingShouldFailIfANavigationHasAnInvalidOnDeleteAction()
 {
     this.ParseNavigationExpectedErrors(
         @"<NavigationProperty Name=""Navigation"" Type=""Test.EntityType"">
             <OnDelete Action=""Foo"" />
           </NavigationProperty>",
         EdmErrorCode.InvalidOnDelete,
         ErrorStrings.CsdlParser_InvalidDeleteAction("Foo"));
 }
Beispiel #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"));
 }
Beispiel #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"));
 }
        public void ValidationShouldFailIfEnumMemberIsSpecifiedButCannotBeFoundTheMember()
        {
            IEdmModel model = GetEdmModel(@"<EnumMember>TestNS2.Color/UnknownMember</EnumMember>");
            IEnumerable <EdmError> errors;

            model.Validate(out errors).Should().BeFalse();
            errors.Should().HaveCount(2);
            errors.Should().Contain(e => e.ErrorCode == EdmErrorCode.InvalidEnumMemberPath &&
                                    e.ErrorMessage == ErrorStrings.CsdlParser_InvalidEnumMemberPath("TestNS2.Color/UnknownMember"));
        }
Beispiel #14
0
        public void ValidationShouldFailIfEnumMemberIsSpecifiedButCannotBeFoundTheMember()
        {
            IEdmModel model = GetEnumAnnotationModel(@"<EnumMember>TestNS2.Color/UnknownMember</EnumMember>");
            IEnumerable <EdmError> errors;

            Assert.False(model.Validate(out errors));
            Assert.Equal(2, errors.Count());
            Assert.Contains(errors, e => e.ErrorCode == EdmErrorCode.InvalidEnumMemberPath &&
                            e.ErrorMessage == ErrorStrings.CsdlParser_InvalidEnumMemberPath("TestNS2.Color/UnknownMember"));
        }
Beispiel #15
0
        public void ValidationShouldFailIfEnumMemberIsSpecifiedButCannotBeFound()
        {
            IEdmModel model = GetEnumAnnotationModel(@"<EnumMember>TestNS2.UnknownColor/Blue</EnumMember>");
            IEnumerable <EdmError> errors;

            Assert.False(model.Validate(out errors));
            var error = Assert.Single(errors);

            Assert.Equal(EdmErrorCode.BadUnresolvedEnumMember, error.ErrorCode);
            Assert.Equal(ErrorStrings.Bad_UnresolvedEnumMember("Blue"), error.ErrorMessage);
        }
Beispiel #16
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"));
        }
Beispiel #17
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"));
        }
Beispiel #18
0
 public void ValidationShouldFailIfNavigationParterIsSpecifiedButCannotBeFound()
 {
     this.ValidateNavigationWithExpectedErrors(@"<NavigationProperty Name=""Navigation"" Type=""Test.EntityType"" Partner=""Nonexistent"" />",
                                               new[]
     {
         EdmErrorCode.BadUnresolvedNavigationPropertyPath,
         EdmErrorCode.UnresolvedNavigationPropertyPartnerPath
     },
                                               new[]
     {
         ErrorStrings.Bad_UnresolvedNavigationPropertyPath("Nonexistent", "Test.EntityType"),
         string.Format("Cannot resolve partner path for navigation property '{0}'.", "Navigation")
     });
 }
Beispiel #19
0
 public void ParsingShouldFailIfNavigationNullableIsNotTrueOrFalse()
 {
     this.ParseNavigationExpectedErrors(@"<NavigationProperty Name=""Navigation"" Type=""Test.EntityType"" Nullable=""foo""/>",
                                        EdmErrorCode.InvalidBoolean,
                                        ErrorStrings.ValueParser_InvalidBoolean("foo"));
 }
Beispiel #20
0
 public void ValidationShouldFailIfNavigationTypeIsPrimitiveCollectionType()
 {
     this.ValidateNavigationWithExpectedErrors(@"<NavigationProperty Name=""Navigation"" Type=""Collection(Edm.Int32)"" />",
                                               EdmErrorCode.BadUnresolvedEntityType,
                                               ErrorStrings.Bad_UnresolvedEntityType("Edm.Int32"));
 }
Beispiel #21
0
 public void ParsingShouldFailIfNavigationTypeIsEmpty()
 {
     this.ParseNavigationExpectedErrors(@"<NavigationProperty Name=""Navigation"" Type="""" />",
                                        EdmErrorCode.InvalidTypeName,
                                        ErrorStrings.CsdlParser_InvalidTypeName(""));
 }
Beispiel #22
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);
        }
Beispiel #23
0
 public void ValidationShouldFailIfNavigationTypeIsACollectionButElementTypeDoesNotExist()
 {
     this.ValidateNavigationWithExpectedErrors(@"<NavigationProperty Name=""Navigation"" Type=""Collection(Fake.Nonexistent)"" />",
                                               EdmErrorCode.BadUnresolvedEntityType,
                                               ErrorStrings.Bad_UnresolvedEntityType("Fake.Nonexistent"));
 }
        public void ValidationShouldFailIfEnumMemberIsSpecifiedButCannotBeFound()
        {
            IEdmModel model = GetEdmModel(@"<EnumMember>TestNS2.UnknownColor/Blue</EnumMember>");
            IEnumerable <EdmError> errors;

            model.Validate(out errors).Should().BeFalse();
            errors.Should().HaveCount(1);
            errors.Should().Contain(e => e.ErrorCode == EdmErrorCode.BadUnresolvedEnumMember && e.ErrorMessage == ErrorStrings.Bad_UnresolvedEnumMember("Blue"));
        }
Beispiel #25
0
 /// <summary>
 /// Constructs an appropriate exception message from the set of parsing errors.
 /// </summary>
 /// <param name="parseErrors">The parse errors.</param>
 /// <returns>The exception message.</returns>
 private static string ConstructMessage(IEnumerable <EdmError> parseErrors)
 {
     return(ErrorStrings.EdmParseException_ErrorsEncounteredInEdmx(string.Join(Environment.NewLine, parseErrors.Select(p => p.ToString()).ToArray())));
 }
Beispiel #26
0
 public void ValidationShouldFailIfNavigationParterIsSpecifiedButCannotBeFound()
 {
     this.ValidateNavigationWithExpectedErrors(@"<NavigationProperty Name=""Navigation"" Type=""Test.EntityType"" Partner=""Nonexistent"" />",
                                               EdmErrorCode.BadUnresolvedNavigationPropertyPath,
                                               ErrorStrings.Bad_UnresolvedNavigationPropertyPath("Nonexistent", "Test.EntityType"));
 }