private void ParseBindingWithExpectedErrors(string bindingText, EdmErrorCode?errorCode = null, params string[] messages) { const string template = @"<edmx:Edmx Version=""4.0"" xmlns:edmx=""http://docs.oasis-open.org/odata/ns/edmx""> <edmx:DataServices> <Schema Namespace=""Test"" xmlns=""http://docs.oasis-open.org/odata/ns/edm""> <EntityContainer Name=""Container""> <EntitySet Name=""EntitySet"" EntityType=""Test.EntityType""> {0} </EntitySet> </EntityContainer> </Schema> </edmx:DataServices> </edmx:Edmx>"; string modelText = string.Format(template, bindingText); IEdmModel model; IEnumerable <EdmError> errors; bool result = CsdlReader.TryParse(XElement.Parse(modelText).CreateReader(), out model, out errors); if (errorCode != null) { result.Should().BeFalse(); errors.Should().HaveCount(messages.Length); foreach (var message in messages) { errors.Should().Contain(e => e.ErrorCode == errorCode && e.ErrorMessage == message); } } }
private void ParseNavigationExpectedErrors(string navigationText, EdmErrorCode?errorCode = null, string message = null) { if (errorCode != null) { ParseNavigationExpectedErrors(navigationText, new[] { errorCode.Value }, new[] { message }); } else { ParseNavigationExpectedErrors(navigationText, new EdmErrorCode[0], new string[0]); } }
private void ParseReferentialConstraint(string referentialConstraintText, EdmErrorCode?errorCode = null, params string[] messages) { const string template = @"<edmx:Edmx Version=""4.0"" xmlns:edmx=""http://docs.oasis-open.org/odata/ns/edmx""> <edmx:DataServices> <Schema Namespace=""Test"" xmlns=""http://docs.oasis-open.org/odata/ns/edm""> <EntityType Name=""EntityType""> <Key> <PropertyRef Name=""ID1"" /> <PropertyRef Name=""ID2"" /> </Key> <Property Name=""ID1"" Type=""Edm.Int32"" Nullable=""false"" /> <Property Name=""ID2"" Type=""Edm.Int32"" Nullable=""false"" /> <Property Name=""ForeignKeyId1"" Type=""Edm.Int32"" /> <Property Name=""ForeignKeyId2"" Type=""Edm.Int32"" /> <NavigationProperty Name=""Navigation"" Type=""Test.EntityType"" Nullable=""true""> {0} </NavigationProperty> </EntityType> </Schema> </edmx:DataServices> </edmx:Edmx>"; string modelText = string.Format(template, referentialConstraintText); IEdmModel model; IEnumerable <EdmError> errors; bool result = CsdlReader.TryParse(XElement.Parse(modelText).CreateReader(), out model, out errors); if (errorCode != null) { result.Should().BeFalse(); errors.Should().HaveCount(messages.Length); foreach (var message in messages) { errors.Should().Contain(e => e.ErrorCode == errorCode && e.ErrorMessage == message); } } }