public void ValidationShouldFailIfAConstraintOnANonExistentReferencedPropertyIsFound() { this.ValidateReferentialConstraintWithExpectedErrors( @"<ReferentialConstraint Property=""ForeignKeyId1"" ReferencedProperty=""NonExistent"" />", EdmErrorCode.BadUnresolvedProperty, ErrorStrings.Bad_UnresolvedProperty("NonExistent")); }
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 ValidationShouldFailIfATypeCastIsFollowedByANonExistentProperty() { this.ValidateBindingWithExpectedErrors( @"<NavigationPropertyBinding Path=""Test.DerivedEntityType/NonExistent"" Target=""EntitySet"" />", EdmErrorCode.BadUnresolvedNavigationPropertyPath, ErrorStrings.Bad_UnresolvedNavigationPropertyPath("Test.DerivedEntityType/NonExistent", "Test.EntityType")); }
public void ValidationShouldFailIfADerivedPropertyIsUsedWithoutATypeCast() { this.ValidateBindingWithExpectedErrors( @"<NavigationPropertyBinding Path=""DerivedNavigation"" Target=""EntitySet"" />", EdmErrorCode.BadUnresolvedNavigationPropertyPath, ErrorStrings.Bad_UnresolvedNavigationPropertyPath("DerivedNavigation", "Test.EntityType")); }
public void ValidationShouldFailIfAContainerQualifiedNameIsUsedForTheTargetOfABinding() { this.ValidateBindingWithExpectedErrors( @"<NavigationPropertyBinding Path=""Navigation"" Target=""Container.EntitySet"" />", EdmErrorCode.BadUnresolvedEntitySet, ErrorStrings.Bad_UnresolvedEntitySet("Container.EntitySet")); }
public void ValidationShouldFailIfABindingToANonExistentSetIsFound() { this.ValidateBindingWithExpectedErrors( @"<NavigationPropertyBinding Path=""Navigation"" Target=""NonExistent"" />", EdmErrorCode.BadUnresolvedEntitySet, ErrorStrings.Bad_UnresolvedEntitySet("NonExistent")); }
public void ParsingShouldFailIfANavigationIsMissingType() { this.ParseNavigationExpectedErrors( @"<NavigationProperty Name=""Navigation"" />", EdmErrorCode.MissingAttribute, ErrorStrings.XmlParser_MissingAttribute("Type", "NavigationProperty")); }
public void ParsingShouldFailIfABindingHasExtraAttributes() { this.ParseBindingWithExpectedErrors( @"<NavigationPropertyBinding Path=""Navigation"" Target=""EntitySet"" Something=""else"" Foo=""bar"" />", EdmErrorCode.UnexpectedXmlAttribute, ErrorStrings.XmlParser_UnexpectedAttribute("Something"), ErrorStrings.XmlParser_UnexpectedAttribute("Foo")); }
public void ParsingShouldFailIfANavigationHasAnInvalidOnDeleteAction() { this.ParseNavigationExpectedErrors( @"<NavigationProperty Name=""Navigation"" Type=""Test.EntityType""> <OnDelete Action=""Foo"" /> </NavigationProperty>", EdmErrorCode.InvalidOnDelete, ErrorStrings.CsdlParser_InvalidDeleteAction("Foo")); }
public void ParsingShouldFailIfAConstraintHasExtraAttributes() { this.ParseReferentialConstraintWithExpectedErrors( @" <ReferentialConstraint Property=""ForeignKeyId1"" ReferencedProperty=""ID1"" Something=""else"" Foo=""bar"" />", EdmErrorCode.UnexpectedXmlAttribute, ErrorStrings.XmlParser_UnexpectedAttribute("Something"), ErrorStrings.XmlParser_UnexpectedAttribute("Foo")); }
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 ParsingShouldFailIfAConstraintHasAnnotations() { const string invalidConstraint = @" <ReferentialConstraint Property=""ForeignKeyId1"" ReferencedProperty=""ID1""> <Annotation Term=""FQ.NS.Term""/> </ReferentialConstraint>"; this.ParseReferentialConstraintWithExpectedErrors( invalidConstraint, EdmErrorCode.UnexpectedXmlElement, ErrorStrings.XmlParser_UnexpectedElement("Annotation")); }
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")); }
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")); }
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")); }
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)); }
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")); }
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")); }
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")); }
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())); }
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")); }
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); }
public void ValidationShouldFailIfNavigationParterIsSpecifiedButCannotBeFound() { this.ValidateNavigationWithExpectedErrors(@"<NavigationProperty Name=""Navigation"" Type=""Test.EntityType"" Partner=""Nonexistent"" />", EdmErrorCode.BadUnresolvedNavigationPropertyPath, ErrorStrings.Bad_UnresolvedNavigationPropertyPath("Nonexistent", "Test.EntityType")); }
public void ValidationShouldFailIfNavigationTypeIsACollectionButElementTypeDoesNotExist() { this.ValidateNavigationWithExpectedErrors(@"<NavigationProperty Name=""Navigation"" Type=""Collection(Fake.Nonexistent)"" />", EdmErrorCode.BadUnresolvedEntityType, ErrorStrings.Bad_UnresolvedEntityType("Fake.Nonexistent")); }
public void ValidationShouldFailIfNavigationTypeIsPrimitiveCollectionType() { this.ValidateNavigationWithExpectedErrors(@"<NavigationProperty Name=""Navigation"" Type=""Collection(Edm.Int32)"" />", EdmErrorCode.BadUnresolvedEntityType, ErrorStrings.Bad_UnresolvedEntityType("Edm.Int32")); }
public void ParsingShouldFailIfNavigationNullableIsNotTrueOrFalse() { this.ParseNavigationExpectedErrors(@"<NavigationProperty Name=""Navigation"" Type=""Test.EntityType"" Nullable=""foo""/>", EdmErrorCode.InvalidBoolean, ErrorStrings.ValueParser_InvalidBoolean("foo")); }
public void ParsingShouldFailIfNavigationTypeIsEmpty() { this.ParseNavigationExpectedErrors(@"<NavigationProperty Name=""Navigation"" Type="""" />", EdmErrorCode.InvalidTypeName, ErrorStrings.CsdlParser_InvalidTypeName("")); }