public void HomogeneousCollectionReaderWithoutMetadataAtomTest() { IEnumerable <PayloadReaderTestDescriptor> testDescriptors = new[] { // Primitive collection with only nulls new PayloadReaderTestDescriptor(this.PayloadTestDescriptorSettings) { PayloadElement = new PrimitiveCollection( PayloadBuilder.PrimitiveValue(null), PayloadBuilder.PrimitiveValue(null) ).CollectionName(null), }, // Primitive collection with type names on string values new PayloadReaderTestDescriptor(this.PayloadTestDescriptorSettings) { PayloadElement = new PrimitiveCollection( PayloadBuilder.PrimitiveValue("foo"), PayloadBuilder.PrimitiveValue("bar") ).CollectionName(null), }, // Primitive collection with type names on Int32 values new PayloadReaderTestDescriptor(this.PayloadTestDescriptorSettings) { PayloadElement = new PrimitiveCollection( PayloadBuilder.PrimitiveValue(1), PayloadBuilder.PrimitiveValue(2) ).CollectionName(null), }, // Primitive collection without type names on some string values new PayloadReaderTestDescriptor(this.PayloadTestDescriptorSettings) { PayloadElement = new PrimitiveCollection( new PrimitiveValue("Edm.String", "foo"), new PrimitiveValue(/*fullTypeName*/ null, "bar") ).CollectionName(null), }, // Primitive collection without type names on string values new PayloadReaderTestDescriptor(this.PayloadTestDescriptorSettings) { PayloadElement = new PrimitiveCollection( new PrimitiveValue(/*fullTypeName*/ null, "foo"), new PrimitiveValue(/*fullTypeName*/ null, "bar") ).CollectionName(null), }, // Primitive collection with type names on Int32 values and null values new PayloadReaderTestDescriptor(this.PayloadTestDescriptorSettings) { PayloadElement = new PrimitiveCollection( PayloadBuilder.PrimitiveValue(1), PayloadBuilder.PrimitiveValue(null), PayloadBuilder.PrimitiveValue(2), PayloadBuilder.PrimitiveValue(null) ).CollectionName(null), }, // Complex collection with type names on complex values new PayloadReaderTestDescriptor(this.PayloadTestDescriptorSettings) { PayloadElement = new ComplexInstanceCollection( PayloadBuilder.ComplexValue("TestModel.ComplexType").PrimitiveProperty("StringProperty", "abc"), PayloadBuilder.ComplexValue("TestModel.ComplexType").PrimitiveProperty("StringProperty", "123") ).CollectionName(null), }, // Complex collection with type names on complex values and null values new PayloadReaderTestDescriptor(this.PayloadTestDescriptorSettings) { PayloadElement = new ComplexInstanceCollection( PayloadBuilder.ComplexValue("TestModel.ComplexType").PrimitiveProperty("StringProperty", "abc"), PayloadBuilder.ComplexValue(null, /*isNull*/ true), PayloadBuilder.ComplexValue("TestModel.ComplexType").PrimitiveProperty("StringProperty", "123") ).CollectionName(null), }, // Complex collection without type names on complex values new PayloadReaderTestDescriptor(this.PayloadTestDescriptorSettings) { PayloadElement = new ComplexInstanceCollection( PayloadBuilder.ComplexValue().PrimitiveProperty("Name", "Clemens"), PayloadBuilder.ComplexValue().PrimitiveProperty("Name", "Vitek") ).CollectionName(null), }, // Complex collection without type names on complex values and null values new PayloadReaderTestDescriptor(this.PayloadTestDescriptorSettings) { PayloadElement = new ComplexInstanceCollection( PayloadBuilder.ComplexValue().PrimitiveProperty("FirstName", "Clemens"), PayloadBuilder.ComplexValue(null, /*isNull*/ true), PayloadBuilder.ComplexValue().PrimitiveProperty("LastName", "Kerer") ).CollectionName(null), }, }; this.CombinatorialEngineProvider.RunCombinations( testDescriptors, this.ReaderTestConfigurationProvider.AtomFormatConfigurations, (testDescriptor, testConfiguration) => { testDescriptor.RunTest(testConfiguration); }); }
public void JsonLightTaupoSerializerEntryTest() { var testCases = new JsonLightSerializerTestCase[] { // Entry with only ID new JsonLightSerializerTestCase { PayloadElement = PayloadBuilder.Entity() .PrimitiveProperty("ID", (long)42) .WithContextUri("http://odata.org/metadatauri"), ExpectedJson = @" { """ + JsonLightConstants.ODataPropertyAnnotationSeparator + JsonLightConstants.ODataContextAnnotationName + @""":""http://odata.org/metadatauri"", ""ID"":42 }" }, // Entry with ID and typename new JsonLightSerializerTestCase { PayloadElement = PayloadBuilder.Entity("TestModel.Customer") .PrimitiveProperty("ID", (long)42) .WithContextUri("http://odata.org/metadatauri"), ExpectedJson = @" { """ + JsonLightConstants.ODataPropertyAnnotationSeparator + JsonLightConstants.ODataContextAnnotationName + @""":""http://odata.org/metadatauri"", """ + JsonLightConstants.ODataPropertyAnnotationSeparator + JsonLightConstants.ODataTypeAnnotationName + @""":""TestModel.Customer"", ""ID"":42 }" }, // Entry with all metadata expanded new JsonLightSerializerTestCase { PayloadElement = PayloadBuilder.Entity("TestModel.CustomerWithImage") .Id("CustomerId") .ETag("etag") .WithEditLink("http://odata.org/editlink") .WithSelfLink("http://odata.org/readlink") .WithStreamContentType("image/jpg") .WithStreamEditLink("http://odata.org/streameditlink") .WithStreamSourceLink("http://odata.org/streamreadlink") .WithStreamETag("stream-etag") .PrimitiveProperty("ID", (long)42) .Operation(new ServiceOperationDescriptor { IsAction = true, Metadata = "./metadata", Target = "http://odata.org/target", Title = "ActionTitle" }) .Operation(new ServiceOperationDescriptor { IsAction = true, Metadata = "./metadata2", Target = "http://odata.org/target2", Title = "ActionTitle2" }) .Operation(new ServiceOperationDescriptor { IsAction = false, Metadata = "./metadata", Target = "http://odata.org/target", Title = "ActionTitle" }) .Operation(new ServiceOperationDescriptor { IsAction = false, Metadata = "./metadata", Target = "http://odata.org/target2", Title = "ActionTitle2" }) .WithContextUri("http://odata.org/metadatauri"), ExpectedJson = @" { """ + JsonLightConstants.ODataPropertyAnnotationSeparator + JsonLightConstants.ODataContextAnnotationName + @""":""http://odata.org/metadatauri"", """ + JsonLightConstants.ODataPropertyAnnotationSeparator + JsonLightConstants.ODataTypeAnnotationName + @""":""TestModel.CustomerWithImage"", """ + JsonLightConstants.ODataPropertyAnnotationSeparator + JsonLightConstants.ODataIdAnnotationName + @""":""CustomerId"", """ + JsonLightConstants.ODataPropertyAnnotationSeparator + JsonLightConstants.ODataETagAnnotationName + @""":""etag"", """ + JsonLightConstants.ODataPropertyAnnotationSeparator + JsonLightConstants.ODataEditLinkAnnotationName + @""":""http://odata.org/editlink"", """ + JsonLightConstants.ODataPropertyAnnotationSeparator + JsonLightConstants.ODataReadLinkAnnotationName + @""":""http://odata.org/readlink"", """ + JsonLightConstants.ODataPropertyAnnotationSeparator + JsonLightConstants.ODataMediaEditLinkAnnotationName + @""":""http://odata.org/streameditlink"", """ + JsonLightConstants.ODataPropertyAnnotationSeparator + JsonLightConstants.ODataMediaReadLinkAnnotationName + @""":""http://odata.org/streamreadlink"", """ + JsonLightConstants.ODataPropertyAnnotationSeparator + JsonLightConstants.ODataMediaContentTypeAnnotationName + @""":""image/jpg"", """ + JsonLightConstants.ODataPropertyAnnotationSeparator + JsonLightConstants.ODataMediaETagAnnotationName + @""":""stream-etag"", """ + JsonLightConstants.ODataPropertyAnnotationSeparator + JsonLightConstants.ODataActionsAnnotationName + @""":{ ""./metadata"":[{ ""title"":""ActionTitle"", ""target"":""http://odata.org/target""}], ""./metadata2"":[{ ""title"":""ActionTitle2"", ""target"":""http://odata.org/target2""}]}, """ + JsonLightConstants.ODataPropertyAnnotationSeparator + JsonLightConstants.ODataFunctionsAnnotationName + @""":{ ""./metadata"":[{ ""title"":""ActionTitle"", ""target"":""http://odata.org/target""}, { ""title"":""ActionTitle2"", ""target"":""http://odata.org/target2""}]}, ""ID"":42 }" }, // Entry with deferred navigation and association properties new JsonLightSerializerTestCase { PayloadElement = PayloadBuilder.Entity("TestModel.Customer") .PrimitiveProperty("ID", (long)42) .NavigationProperty("NavProp1", "http://odata.org/NavProp1", "http://odata.org/AssocProp1") .NavigationProperty("NavProp2", "http://odata.org/NavProp2") .NavigationProperty("NavProp3", null, "http://odata.org/AssocProp3") .WithContextUri("http://odata.org/metadatauri"), ExpectedJson = @" { """ + JsonLightConstants.ODataPropertyAnnotationSeparator + JsonLightConstants.ODataContextAnnotationName + @""":""http://odata.org/metadatauri"", """ + JsonLightConstants.ODataPropertyAnnotationSeparator + JsonLightConstants.ODataTypeAnnotationName + @""":""TestModel.Customer"", ""ID"":42, """ + JsonLightUtils.GetPropertyAnnotationName("NavProp1", JsonLightConstants.ODataNavigationLinkUrlAnnotationName) + @""":""http://odata.org/NavProp1"", """ + JsonLightUtils.GetPropertyAnnotationName("NavProp1", JsonLightConstants.ODataAssociationLinkUrlAnnotationName) + @""":""http://odata.org/AssocProp1"", """ + JsonLightUtils.GetPropertyAnnotationName("NavProp2", JsonLightConstants.ODataNavigationLinkUrlAnnotationName) + @""":""http://odata.org/NavProp2"", """ + JsonLightUtils.GetPropertyAnnotationName("NavProp3", JsonLightConstants.ODataAssociationLinkUrlAnnotationName) + @""":""http://odata.org/AssocProp3"" }" }, // Entry with navigation link with expanded entry new JsonLightSerializerTestCase { PayloadElement = PayloadBuilder.Entity("TestModel.Customer") .PrimitiveProperty("ID", (long)42) .ExpandedNavigationProperty("NavProp1", PayloadBuilder.Entity("TestModel.Order").PrimitiveProperty("ID", ((long)43))) .ExpandedNavigationProperty("NavProp2", PayloadBuilder.Entity("TestModel.Order").PrimitiveProperty("ID", ((long)43)), "http://odata.org/NavProp2") .ExpandedNavigationProperty("NavProp3", PayloadBuilder.Entity("TestModel.Order").PrimitiveProperty("ID", ((long)43)), new DeferredLink { UriString = "http://odata.org/AssocProp3" }) .WithContextUri("http://odata.org/metadatauri"), ExpectedJson = @" { """ + JsonLightConstants.ODataPropertyAnnotationSeparator + JsonLightConstants.ODataContextAnnotationName + @""":""http://odata.org/metadatauri"", """ + JsonLightConstants.ODataPropertyAnnotationSeparator + JsonLightConstants.ODataTypeAnnotationName + @""":""TestModel.Customer"", ""ID"":42, ""NavProp1"":{ """ + JsonLightConstants.ODataPropertyAnnotationSeparator + JsonLightConstants.ODataTypeAnnotationName + @""":""TestModel.Order"",""ID"":43 }, """ + JsonLightUtils.GetPropertyAnnotationName("NavProp2", JsonLightConstants.ODataNavigationLinkUrlAnnotationName) + @""":""http://odata.org/NavProp2"", ""NavProp2"":{ """ + JsonLightConstants.ODataPropertyAnnotationSeparator + JsonLightConstants.ODataTypeAnnotationName + @""":""TestModel.Order"",""ID"":43 }, """ + JsonLightUtils.GetPropertyAnnotationName("NavProp3", JsonLightConstants.ODataAssociationLinkUrlAnnotationName) + @""":""http://odata.org/AssocProp3"", ""NavProp3"":{ """ + JsonLightConstants.ODataPropertyAnnotationSeparator + JsonLightConstants.ODataTypeAnnotationName + @""":""TestModel.Order"",""ID"":43 } }" }, // Entry with navigation link with expanded feed new JsonLightSerializerTestCase { PayloadElement = PayloadBuilder.Entity("TestModel.Customer") .PrimitiveProperty("ID", (long)42) .ExpandedNavigationProperty("NavProp1", PayloadBuilder.EntitySet()) .ExpandedNavigationProperty("NavProp2", PayloadBuilder.EntitySet(), "http://odata.org/NavProp2") .ExpandedNavigationProperty("NavProp3", PayloadBuilder.EntitySet(), new DeferredLink { UriString = "http://odata.org/AssocProp3" }) .WithContextUri("http://odata.org/metadatauri"), ExpectedJson = @" { """ + JsonLightConstants.ODataPropertyAnnotationSeparator + JsonLightConstants.ODataContextAnnotationName + @""":""http://odata.org/metadatauri"", """ + JsonLightConstants.ODataPropertyAnnotationSeparator + JsonLightConstants.ODataTypeAnnotationName + @""":""TestModel.Customer"", ""ID"":42, ""NavProp1"":[], """ + JsonLightUtils.GetPropertyAnnotationName("NavProp2", JsonLightConstants.ODataNavigationLinkUrlAnnotationName) + @""":""http://odata.org/NavProp2"", ""NavProp2"":[], """ + JsonLightUtils.GetPropertyAnnotationName("NavProp3", JsonLightConstants.ODataAssociationLinkUrlAnnotationName) + @""":""http://odata.org/AssocProp3"", ""NavProp3"":[] }" }, }; this.CombinatorialEngineProvider.RunCombinations( testCases, (testCase) => { PayloadFormatVersionAnnotatingVisitor.AnnotateJsonLight(testCase.PayloadElement, DataServiceProtocolVersion.Unspecified, false); JsonValue actualValue = this.JsonLightSerializer.ConvertToJsonLightValue(testCase.PayloadElement); JsonValue expectedValue = JsonTextPreservingParser.ParseValue(new StringReader(testCase.ExpectedJson)); this.JsonValueComparer.Compare(expectedValue, actualValue); }); }
public void JsonLightTaupoSerializerEntityReferenceLinkTest() { var testCases = new JsonLightSerializerTestCase[] { // Single entity reference link new JsonLightSerializerTestCase { PayloadElement = PayloadBuilder.DeferredLink("http://odata.org/erl") .WithContextUri("http://odata.org/metadatauri"), ExpectedJson = @" { """ + JsonLightConstants.ODataPropertyAnnotationSeparator + JsonLightConstants.ODataContextAnnotationName + @""":""http://odata.org/metadatauri"", """ + JsonLightConstants.ODataPropertyAnnotationSeparator + JsonLightConstants.ODataIdAnnotationName + @""":""http://odata.org/erl"" }" }, // Collection of entity reference links new JsonLightSerializerTestCase { PayloadElement = PayloadBuilder.LinkCollection() .Item(PayloadBuilder.DeferredLink("http://odata.org/erl1")) .Item(PayloadBuilder.DeferredLink("http://odata.org/erl2")) .WithContextUri("http://odata.org/metadatauri"), ExpectedJson = @" { """ + JsonLightConstants.ODataPropertyAnnotationSeparator + JsonLightConstants.ODataContextAnnotationName + @""":""http://odata.org/metadatauri"", """ + JsonLightConstants.ODataValuePropertyName + @""":[ { """ + JsonLightConstants.ODataPropertyAnnotationSeparator + JsonLightConstants.ODataIdAnnotationName + @""":""http://odata.org/erl1"" }, { """ + JsonLightConstants.ODataPropertyAnnotationSeparator + JsonLightConstants.ODataIdAnnotationName + @""":""http://odata.org/erl2"" } ] }" }, // Collection of entity reference links with inline count and next link new JsonLightSerializerTestCase { PayloadElement = PayloadBuilder.LinkCollection() .Item(PayloadBuilder.DeferredLink("http://odata.org/erl1")) .Item(PayloadBuilder.DeferredLink("http://odata.org/erl2")) .InlineCount(42) .NextLink("http://odata.org/nextlink") .WithContextUri("http://odata.org/metadatauri"), ExpectedJson = @" { """ + JsonLightConstants.ODataPropertyAnnotationSeparator + JsonLightConstants.ODataContextAnnotationName + @""":""http://odata.org/metadatauri"", """ + JsonLightConstants.ODataPropertyAnnotationSeparator + JsonLightConstants.ODataCountAnnotationName + @""": 42, """ + JsonLightConstants.ODataValuePropertyName + @""":[ { """ + JsonLightConstants.ODataPropertyAnnotationSeparator + JsonLightConstants.ODataIdAnnotationName + @""":""http://odata.org/erl1"" }, { """ + JsonLightConstants.ODataPropertyAnnotationSeparator + JsonLightConstants.ODataIdAnnotationName + @""":""http://odata.org/erl2"" } ], """ + JsonLightConstants.ODataPropertyAnnotationSeparator + JsonLightConstants.ODataNextLinkAnnotationName + @""":""http://odata.org/nextlink"" }" }, }; this.CombinatorialEngineProvider.RunCombinations( testCases, (testCase) => { PayloadFormatVersionAnnotatingVisitor.AnnotateJsonLight(testCase.PayloadElement, DataServiceProtocolVersion.Unspecified, false); JsonValue actualValue = this.JsonLightSerializer.ConvertToJsonLightValue(testCase.PayloadElement); JsonValue expectedValue = JsonTextPreservingParser.ParseValue(new StringReader(testCase.ExpectedJson)); this.JsonValueComparer.Compare(expectedValue, actualValue); }); }
/// <summary> /// Generates various payloads with different link properties set to the specified cross reference value. /// </summary> /// <param name="crossReferenceLink">The cross reference link values to set on each payload.</param> /// <param name="testConfiguration">The test configuration to use.</param> /// <returns>The payloads.</returns> private static IEnumerable <ODataPayloadElement> GeneratePayloadElementsWithCrossReferenceLinks(string crossReferenceLink, ReaderTestConfiguration testConfiguration) { List <ODataPayloadElement> payloadElements = new List <ODataPayloadElement>(); // Entry with edit link payloadElements.Add(PayloadBuilder.Entity("TestModel.Address").PrimitiveProperty("Zip", 12345).WithEditLink(crossReferenceLink)); // Entry with self link payloadElements.Add(PayloadBuilder.Entity("TestModel.Address").PrimitiveProperty("Zip", 98765).WithSelfLink(crossReferenceLink)); // Entry with deferred navprop payloadElements.Add(PayloadBuilder.Entity("TestModel.CityType").DeferredNavigationProperty("CityHall", PayloadBuilder.DeferredLink(crossReferenceLink))); // Entry with expanded navprop payloadElements.Add(PayloadBuilder.Entity("TestModel.CityType").ExpandedNavigationProperty("PoliceStation", PayloadBuilder.Entity("TestModel.OfficeType").PrimitiveProperty("Id", 0), crossReferenceLink)); if (!testConfiguration.IsRequest) { // Entry with deferred navprop with association link payloadElements.Add(PayloadBuilder.Entity("TestModel.CityType").DeferredNavigationProperty("DOL", PayloadBuilder.DeferredLink("http://odata.org"), PayloadBuilder.DeferredLink(crossReferenceLink))); // Entry with expanded navprop with association link payloadElements.Add(PayloadBuilder.Entity("TestModel.CityType").NavigationProperty( PayloadBuilder.ExpandedNavigationProperty("PoliceStation", PayloadBuilder.Entity("TestModel.OfficeType").PrimitiveProperty("Id", 0), "http://odata.org", crossReferenceLink))); // Entry with stream property with read link payloadElements.Add(PayloadBuilder.Entity("TestModel.CityType").StreamProperty("Skyline", crossReferenceLink)); // Entry with stream property with edit link payloadElements.Add(PayloadBuilder.Entity("TestModel.CityType").StreamProperty("Skyline", null, crossReferenceLink)); // Feed with multiple entries referencing same link payloadElements.Add(PayloadBuilder.EntitySet( new[] { PayloadBuilder.Entity("TestModel.CityType").DeferredNavigationProperty("CityHall", PayloadBuilder.DeferredLink(crossReferenceLink)), PayloadBuilder.Entity("TestModel.CityType").DeferredNavigationProperty("CityHall", PayloadBuilder.DeferredLink(crossReferenceLink)), })); } return(payloadElements); }
public void ReadBindableODataOperationTest() { EdmModel model = Test.OData.Utils.Metadata.TestModels.BuildTestModel() as EdmModel; EdmEntityContainer defaultContainer = model.FindEntityContainer("DefaultContainer") as EdmEntityContainer; IEdmEntitySet cities = defaultContainer.FindEntitySet("Cities"); IEdmEntityType cityType = (IEdmEntityType)model.FindDeclaredType("TestModel.CityType"); var addressInCity1BindableFunctionWithOverload = defaultContainer.AddActionAndActionImport(model, "AddressInCity", EdmCoreModel.Instance.GetBoolean(isNullable: true), null, true); var addressInCity1Action = addressInCity1BindableFunctionWithOverload.Action.AsEdmAction(); addressInCity1Action.AddParameter("city", new EdmEntityTypeReference(cityType, isNullable: true)); addressInCity1Action.AddParameter("address", EdmCoreModel.Instance.GetString(isNullable: true)); var funcWithOneParamImport = defaultContainer.AddFunctionAndFunctionImport(model, "BindableFunctionWithOverload", EdmCoreModel.Instance.GetInt32(true), null, false, true); var funcWithOneParam = funcWithOneParamImport.Function.AsEdmFunction(); funcWithOneParam.AddParameter("p1", new EdmEntityTypeReference(cityType, isNullable: true)); var funcWithTwoParamImport = defaultContainer.AddFunctionAndFunctionImport(model, "BindableFunctionWithOverload", EdmCoreModel.Instance.GetInt32(true), null, false, true); var funcWithTwoParam = funcWithTwoParamImport.Function.AsEdmFunction(); funcWithTwoParam.AddParameter("p1", new EdmEntityTypeReference(cityType, isNullable: true)); funcWithTwoParam.AddParameter("p2", EdmCoreModel.Instance.GetString(isNullable: true)); var testCases = new[] { new { DebugDescription = "No always bindable operations in payload", Json = "\"#TestModel.PrimitiveResultOperation\":{}", ExpectedServiceOperationDescriptor = new[] { new ServiceOperationDescriptor { IsAction = true, Metadata = "http://odata.org/test/$metadata#TestModel.AddressInCity", Title = "TestModel.AddressInCity", Target = "http://odata.org/test/Cities(1)/TestModel.AddressInCity" }, new ServiceOperationDescriptor { IsFunction = true, Metadata = "http://odata.org/test/$metadata#TestModel.PrimitiveResultOperation", Title = "TestModel.PrimitiveResultOperation", Target = "http://odata.org/test/Cities(1)/TestModel.PrimitiveResultOperation" }, new ServiceOperationDescriptor { IsFunction = true, Metadata = "http://odata.org/test/$metadata#TestModel.BindableFunctionWithOverload" + Uri.EscapeDataString("()"), Title = "TestModel.BindableFunctionWithOverload", Target = "http://odata.org/test/Cities(1)/TestModel.BindableFunctionWithOverload" }, new ServiceOperationDescriptor { IsFunction = true, Metadata = "http://odata.org/test/$metadata#TestModel.BindableFunctionWithOverload" + Uri.EscapeDataString("(p2)"), Title = "TestModel.BindableFunctionWithOverload", Target = "http://odata.org/test/Cities(1)/TestModel.BindableFunctionWithOverload(p2=@p2)" }, } }, new { DebugDescription = "Always bindable operations from default container and always bindable function group in payload", Json = "\"#TestModel.PrimitiveResultOperation\":{},\"#TestModel.AddressInCity\":{},\"#TestModel.BindableFunctionWithOverload\":{}", ExpectedServiceOperationDescriptor = new[] { new ServiceOperationDescriptor { IsAction = true, Metadata = "http://odata.org/test/$metadata#TestModel.AddressInCity", Title = "TestModel.AddressInCity", Target = "http://odata.org/test/Cities(1)/TestModel.AddressInCity" }, new ServiceOperationDescriptor { IsFunction = true, Metadata = "http://odata.org/test/$metadata#TestModel.PrimitiveResultOperation", Title = "TestModel.PrimitiveResultOperation", Target = "http://odata.org/test/Cities(1)/TestModel.PrimitiveResultOperation" }, new ServiceOperationDescriptor { IsFunction = true, Metadata = "http://odata.org/test/$metadata#TestModel.BindableFunctionWithOverload", Title = "TestModel.BindableFunctionWithOverload", Target = "http://odata.org/test/Cities(1)/TestModel.BindableFunctionWithOverload" }, } }, new { DebugDescription = "Always bindable operations and function group with namespace from default container in payload", Json = "\"#TestModel.PrimitiveResultOperation\":{},\"#TestModel.AddressInCity\":{},\"#TestModel.BindableFunctionWithOverload\":{}", ExpectedServiceOperationDescriptor = new[] { new ServiceOperationDescriptor { IsAction = true, Metadata = "http://odata.org/test/$metadata#TestModel.AddressInCity", Title = "TestModel.AddressInCity", Target = "http://odata.org/test/Cities(1)/TestModel.AddressInCity" }, new ServiceOperationDescriptor { IsFunction = true, Metadata = "http://odata.org/test/$metadata#TestModel.PrimitiveResultOperation", Title = "TestModel.PrimitiveResultOperation", Target = "http://odata.org/test/Cities(1)/TestModel.PrimitiveResultOperation" }, new ServiceOperationDescriptor { IsFunction = true, Metadata = "http://odata.org/test/$metadata#TestModel.BindableFunctionWithOverload", Title = "TestModel.BindableFunctionWithOverload", Target = "http://odata.org/test/Cities(1)/TestModel.BindableFunctionWithOverload" }, } }, new { DebugDescription = "Always bindable operations from non-default container and function overload with 1 param in payload", Json = "\"#TestModel.PrimitiveResultOperation\":{},\"#TestModel.AddressInCity\":{},\"#TestModel.BindableFunctionWithOverload(p1)\":{}", ExpectedServiceOperationDescriptor = new[] { new ServiceOperationDescriptor { IsAction = true, Metadata = "http://odata.org/test/$metadata#TestModel.AddressInCity", Title = "TestModel.AddressInCity", Target = "http://odata.org/test/Cities(1)/TestModel.AddressInCity" }, new ServiceOperationDescriptor { IsFunction = true, Metadata = "http://odata.org/test/$metadata#TestModel.PrimitiveResultOperation", Title = "TestModel.PrimitiveResultOperation", Target = "http://odata.org/test/Cities(1)/TestModel.PrimitiveResultOperation" }, new ServiceOperationDescriptor { IsFunction = true, Metadata = "http://odata.org/test/$metadata#TestModel.BindableFunctionWithOverload" + Uri.EscapeDataString("()"), Title = "TestModel.BindableFunctionWithOverload", Target = "http://odata.org/test/Cities(1)/TestModel.BindableFunctionWithOverload" }, new ServiceOperationDescriptor { IsFunction = true, Metadata = "http://odata.org/test/$metadata#TestModel.BindableFunctionWithOverload" + Uri.EscapeDataString("(p2)"), Title = "TestModel.BindableFunctionWithOverload", Target = "http://odata.org/test/Cities(1)/TestModel.BindableFunctionWithOverload(p2=@p2)" }, } }, new { DebugDescription = "Always bindable operations and function overload with 2 params, with namespace from non-default container in payload", Json = "\"#TestModel.PrimitiveResultOperation\":{},\"#TestModel.AddressInCity\":{},\"#TestModel.BindableFunctionWithOverload(p1)\":{}", ExpectedServiceOperationDescriptor = new[] { new ServiceOperationDescriptor { IsAction = true, Metadata = "http://odata.org/test/$metadata#TestModel.AddressInCity", Title = "TestModel.AddressInCity", Target = "http://odata.org/test/Cities(1)/TestModel.AddressInCity" }, new ServiceOperationDescriptor { IsFunction = true, Metadata = "http://odata.org/test/$metadata#TestModel.PrimitiveResultOperation", Title = "TestModel.PrimitiveResultOperation", Target = "http://odata.org/test/Cities(1)/TestModel.PrimitiveResultOperation" }, new ServiceOperationDescriptor { IsFunction = true, Metadata = "http://odata.org/test/$metadata#TestModel.BindableFunctionWithOverload" + Uri.EscapeDataString("()"), Title = "TestModel.BindableFunctionWithOverload", Target = "http://odata.org/test/Cities(1)/TestModel.BindableFunctionWithOverload" }, new ServiceOperationDescriptor { IsFunction = true, Metadata = "http://odata.org/test/$metadata#TestModel.BindableFunctionWithOverload" + Uri.EscapeDataString("(p2)"), Title = "TestModel.BindableFunctionWithOverload", Target = "http://odata.org/test/Cities(1)/TestModel.BindableFunctionWithOverload(p2=@p2)" }, } }, new { DebugDescription = "All of the always bindable operations in payload", Json = "\"#TestModel.PrimitiveResultOperation\":{},\"#TestModel.AddressInCity\":{}," + "\"#TestModel.BindableFunctionWithOverload(p1)\":{},\"#TestModel.BindableFunctionWithOverload(p1,p2)\":{}", ExpectedServiceOperationDescriptor = new[] { new ServiceOperationDescriptor { IsAction = true, Metadata = "http://odata.org/test/$metadata#TestModel.AddressInCity", Title = "TestModel.AddressInCity", Target = "http://odata.org/test/Cities(1)/TestModel.AddressInCity" }, new ServiceOperationDescriptor { IsFunction = true, Metadata = "http://odata.org/test/$metadata#TestModel.PrimitiveResultOperation", Title = "TestModel.PrimitiveResultOperation", Target = "http://odata.org/test/Cities(1)/TestModel.PrimitiveResultOperation" }, new ServiceOperationDescriptor { IsFunction = true, Metadata = "http://odata.org/test/$metadata#TestModel.BindableFunctionWithOverload" + Uri.EscapeDataString("()"), Title = "TestModel.BindableFunctionWithOverload", Target = "http://odata.org/test/Cities(1)/TestModel.BindableFunctionWithOverload" }, new ServiceOperationDescriptor { IsFunction = true, Metadata = "http://odata.org/test/$metadata#TestModel.BindableFunctionWithOverload" + Uri.EscapeDataString("(p2)"), Title = "TestModel.BindableFunctionWithOverload", Target = "http://odata.org/test/Cities(1)/TestModel.BindableFunctionWithOverload(p2=@p2)" }, } }, new { DebugDescription = "All of the always bindable operations with namespace in payload", Json = "\"#TestModel.PrimitiveResultOperation\":{},\"#TestModel.AddressInCity\":{}," + "\"#TestModel.BindableFunctionWithOverload(p1)\":{},\"#TestModel.BindableFunctionWithOverload(p1,p2)\":{}", ExpectedServiceOperationDescriptor = new[] { new ServiceOperationDescriptor { IsAction = true, Metadata = "http://odata.org/test/$metadata#TestModel.AddressInCity", Title = "TestModel.AddressInCity", Target = "http://odata.org/test/Cities(1)/TestModel.AddressInCity" }, new ServiceOperationDescriptor { IsFunction = true, Metadata = "http://odata.org/test/$metadata#TestModel.PrimitiveResultOperation", Title = "TestModel.PrimitiveResultOperation", Target = "http://odata.org/test/Cities(1)/TestModel.PrimitiveResultOperation" }, new ServiceOperationDescriptor { IsFunction = true, Metadata = "http://odata.org/test/$metadata#TestModel.BindableFunctionWithOverload" + Uri.EscapeDataString("()"), Title = "TestModel.BindableFunctionWithOverload", Target = "http://odata.org/test/Cities(1)/TestModel.BindableFunctionWithOverload" }, new ServiceOperationDescriptor { IsFunction = true, Metadata = "http://odata.org/test/$metadata#TestModel.BindableFunctionWithOverload" + Uri.EscapeDataString("(p2)"), Title = "TestModel.BindableFunctionWithOverload", Target = "http://odata.org/test/Cities(1)/TestModel.BindableFunctionWithOverload(p2=@p2)" }, } }, }; IEnumerable <PayloadReaderTestDescriptor> testDescriptors = testCases.Select( t => new PayloadReaderTestDescriptor(this.Settings) { DebugDescription = t.DebugDescription, PayloadEdmModel = model, PayloadElement = PayloadBuilder.Entity("TestModel.CityType") .JsonRepresentation( "{" + "\"" + JsonLightConstants.ODataPropertyAnnotationSeparator + JsonLightConstants.ODataContextAnnotationName + "\":\"http://odata.org/test/$metadata#DefaultContainer.Cities/$entity\"," + "\"" + JsonLightConstants.ODataPropertyAnnotationSeparator + JsonLightConstants.ODataTypeAnnotationName + "\":\"TestModel.CityType\"," + "\"Id\":1," + "\"Name\":\"New York\"," + t.Json + "}") .ExpectedEntityType(cityType, cities), ExpectedResultPayloadElement = (tc) => { var entityInstance = PayloadBuilder.Entity("TestModel.CityType"). PrimitiveProperty("Id", 1). PrimitiveProperty("Name", "New York"). StreamProperty("Skyline", "http://odata.org/test/Cities(1)/Skyline", "http://odata.org/test/Cities(1)/Skyline"). NavigationProperty("CityHall", "http://odata.org/test/Cities(1)/CityHall"). NavigationProperty("DOL", "http://odata.org/test/Cities(1)/DOL"). NavigationProperty("PoliceStation", "http://odata.org/test/Cities(1)/PoliceStation"); foreach (var op in t.ExpectedServiceOperationDescriptor) { entityInstance.OperationDescriptor(op); } return(entityInstance); }, SkipTestConfiguration = tc => tc.IsRequest }); this.CombinatorialEngineProvider.RunCombinations( testDescriptors, this.ReaderTestConfigurationProvider.JsonLightFormatConfigurations, (testDescriptor, testConfiguration) => { if (testConfiguration.IsRequest) { testDescriptor = new PayloadReaderTestDescriptor(testDescriptor); testDescriptor.ExpectedResultNormalizers.Add(tc => RemoveOperationsNormalizer.Normalize); } // These descriptors are already tailored specifically for Json Light and // do not require normalization. testDescriptor.TestDescriptorNormalizers.Clear(); testDescriptor.RunTest(testConfiguration); }); }
public void ParameterReaderJsonLightTest() { EdmModel model = new EdmModel(); model.Fixup(); EdmEntityContainer container = model.EntityContainer as EdmEntityContainer; EdmFunction function = new EdmFunction(container.Namespace, "f1", EdmCoreModel.Instance.GetInt32(true)); function.AddParameter("p1", EdmCoreModel.Instance.GetInt32(false) as EdmTypeReference); function.AddParameter("p2", EdmCoreModel.Instance.GetString(false) as EdmTypeReference); model.AddElement(function); EdmOperationImport f1 = container.FunctionImport(function); ComplexInstance f1Params = PayloadBuilder.ComplexValue().PrimitiveProperty("p1", 42).PrimitiveProperty("p2", "Vienna") .ExpectedFunctionImport(f1); var testCases = new[] { new { DebugDescription = "Custom property annotation for a valid parameter property (before property) - should work.", Json = "{\"" + JsonLightUtils.GetPropertyAnnotationName("p1", "my.custom") + "\":42, \"p1\":42, \"p2\":\"Vienna\"}", ExpectedException = (ExpectedException)null, }, new { DebugDescription = "Custom property annotation for a valid parameter property (after property) - should fail.", Json = "{\"p1\":42, \"" + JsonLightUtils.GetPropertyAnnotationName("p1", "my.custom") + "\":42, \"p2\":\"Vienna\"}", ExpectedException = ODataExpectedExceptions.ODataException("PropertyAnnotationAfterTheProperty", "my.custom", "p1"), }, new { DebugDescription = "OData property annotation for a valid parameter property (before property) - should work.", Json = "{\"" + JsonLightUtils.GetPropertyAnnotationName("p1", JsonLightConstants.ODataTypeAnnotationName) + "\":42, \"p1\":42, \"p2\":\"Vienna\"}", ExpectedException = ODataExpectedExceptions.ODataException("ODataJsonLightParameterDeserializer_PropertyAnnotationForParameters"), }, new { DebugDescription = "OData property annotation for a valid parameter property (after property) - should fail.", Json = "{\"p1\":42, \"" + JsonLightUtils.GetPropertyAnnotationName("p1", JsonLightConstants.ODataTypeAnnotationName) + "\":42, \"p2\":\"Vienna\"}", ExpectedException = ODataExpectedExceptions.ODataException("ODataJsonLightParameterDeserializer_PropertyAnnotationForParameters"), }, new { DebugDescription = "Custom property annotation for an invalid parameter property - should fail.", Json = "{\"" + JsonLightUtils.GetPropertyAnnotationName("p0", "my.custom") + "\":42, \"p1\":42, \"p2\":\"Vienna\"}", ExpectedException = ODataExpectedExceptions.ODataException("ODataJsonLightParameterDeserializer_PropertyAnnotationWithoutPropertyForParameters", "p0"), }, new { DebugDescription = "Custom instance annotation - should work.", Json = "{\"@my.custom\":42, \"p1\":42, \"p2\":\"Vienna\"}", ExpectedException = (ExpectedException)null, }, new { DebugDescription = "OData instance annotation - should fail.", Json = "{\"" + JsonLightConstants.ODataPropertyAnnotationSeparator + JsonLightConstants.ODataTypeAnnotationName + "\":\"Edm.Int32\", \"p1\":42, \"p2\":\"Vienna\"}", ExpectedException = ODataExpectedExceptions.ODataException("ODataJsonLightPropertyAndValueDeserializer_UnexpectedAnnotationProperties", JsonLightConstants.ODataTypeAnnotationName), }, }; var testDescriptors = testCases.Select(testCase => new PayloadReaderTestDescriptor(this.Settings) { DebugDescription = testCase.DebugDescription, PayloadElement = f1Params.DeepCopy().JsonRepresentation(testCase.Json), PayloadEdmModel = model, PayloadKind = ODataPayloadKind.Parameter, ExpectedException = testCase.ExpectedException, }); this.CombinatorialEngineProvider.RunCombinations( testDescriptors, this.ReaderTestConfigurationProvider.JsonLightFormatConfigurations.Where(c => c.IsRequest), (testDescriptor, testConfiguration) => { testDescriptor.ExpectedResultNormalizers.Add(tc => ParameterReaderTests.FixupExpectedCollectionParameterPayloadElement); // These descriptors are already tailored specifically for Json Light and // do not require normalization. testDescriptor.TestDescriptorNormalizers.Clear(); testDescriptor.RunTest(testConfiguration); }); }
/// <summary> /// Creates a feed containing entities of types that derive from the same base /// </summary> /// <param name="model">The entity model schema. The method will modify the model and call Fixup().</param> /// <param name="withTypeNames">True if the payloads should specify type names.</param> /// <returns>The feed containing derived typed entities.</returns> public static IEnumerable <Taupo.OData.Common.PayloadTestDescriptor> GetFeeds(EdmModel model, bool withTypeNames) { ExceptionUtilities.CheckArgumentNotNull(model, "model"); List <Taupo.OData.Common.PayloadTestDescriptor> payloads = new List <Taupo.OData.Common.PayloadTestDescriptor>(); EdmEntityType baseType = model.EntityType("MyBaseType").KeyProperty("Id", (EdmPrimitiveTypeReference)EdmCoreModel.Instance.GetGuid(false)); model.Fixup(); EntityInstance instance = PayloadBuilder.Entity(withTypeNames ? "TestModel." + baseType.Name : null).Property("Id", PayloadBuilder.PrimitiveValue(Guid.NewGuid())); instance.Id = "urn:id"; EntitySetInstance emptySet = PayloadBuilder.EntitySet().WithTypeAnnotation(baseType); payloads.Add(new Taupo.OData.Common.PayloadTestDescriptor() { PayloadEdmModel = model, PayloadElement = emptySet }); var emptySetWithInlineCount = emptySet.DeepCopy(); emptySetWithInlineCount.InlineCount = 0; // Inline count (note we skip for v1 and request because inline count is valid on response only on V2 and above. payloads.Add(new Taupo.OData.Common.PayloadTestDescriptor() { PayloadEdmModel = model, PayloadElement = emptySetWithInlineCount, SkipTestConfiguration = (tc => tc.IsRequest) }); var emptySetWithNextLinkAndCount = emptySet.DeepCopy(); emptySetWithNextLinkAndCount.InlineCount = 0; emptySetWithNextLinkAndCount.NextLink = "http://www.odata.org/Feed"; // inline count + next link payloads.Add(new Taupo.OData.Common.PayloadTestDescriptor() { PayloadEdmModel = model, PayloadElement = emptySetWithNextLinkAndCount, SkipTestConfiguration = (tc => tc.IsRequest) }); var emptySetWithNextLink = emptySet.DeepCopy(); emptySetWithNextLink.NextLink = "http://www.odata.org/Feed"; // next link payloads.Add(new Taupo.OData.Common.PayloadTestDescriptor() { PayloadEdmModel = model, PayloadElement = emptySetWithNextLink, SkipTestConfiguration = (tc => tc.IsRequest) }); EntitySetInstance singleEntity = PayloadBuilder.EntitySet().Append(instance).WithTypeAnnotation(baseType); payloads.Add(new Taupo.OData.Common.PayloadTestDescriptor() { PayloadEdmModel = model, PayloadElement = singleEntity.DeepCopy() }); var singleEntityWithInlineCount = singleEntity.DeepCopy(); singleEntityWithInlineCount.InlineCount = 1; // inline count payloads.Add(new Taupo.OData.Common.PayloadTestDescriptor() { PayloadEdmModel = model, PayloadElement = singleEntityWithInlineCount, SkipTestConfiguration = (tc => tc.IsRequest) }); var singleEntityWithNextLinkAndCount = singleEntity.DeepCopy(); singleEntityWithInlineCount.InlineCount = 1; singleEntityWithNextLinkAndCount.NextLink = "http://www.odata.org/Feed"; // inline count + next link payloads.Add(new Taupo.OData.Common.PayloadTestDescriptor() { PayloadEdmModel = model, PayloadElement = singleEntityWithNextLinkAndCount, SkipTestConfiguration = (tc => tc.IsRequest) }); var singleEntityWithNextLink = singleEntity.DeepCopy(); singleEntityWithNextLink.NextLink = "http://www.odata.org/Feed"; // next link payloads.Add(new Taupo.OData.Common.PayloadTestDescriptor() { PayloadEdmModel = model, PayloadElement = singleEntityWithNextLink, SkipTestConfiguration = (tc => tc.IsRequest) }); EntitySetInstance multipleEntity = PayloadBuilder.EntitySet().Append(instance.GenerateSimilarEntries(3)).WithTypeAnnotation(baseType); payloads.Add(new Taupo.OData.Common.PayloadTestDescriptor() { PayloadEdmModel = model, PayloadElement = multipleEntity }); var multipleEntityWithInlineCount = multipleEntity.DeepCopy(); multipleEntityWithInlineCount.InlineCount = 3; // inline count payloads.Add(new Taupo.OData.Common.PayloadTestDescriptor() { PayloadEdmModel = model, PayloadElement = multipleEntityWithInlineCount, SkipTestConfiguration = (tc => tc.IsRequest) }); var multipleEntityWithNextLinkAndCount = multipleEntity.DeepCopy(); multipleEntityWithNextLinkAndCount.InlineCount = 3; multipleEntityWithNextLinkAndCount.NextLink = "http://www.odata.org/Feed"; // inline count + next link payloads.Add(new Taupo.OData.Common.PayloadTestDescriptor() { PayloadEdmModel = model, PayloadElement = multipleEntityWithNextLinkAndCount, SkipTestConfiguration = (tc => tc.IsRequest) }); var multipleEntityWithNextLink = multipleEntity.DeepCopy(); multipleEntityWithNextLink.NextLink = "http://www.odata.org/Feed"; // next link payloads.Add(new Taupo.OData.Common.PayloadTestDescriptor() { PayloadEdmModel = model, PayloadElement = multipleEntityWithNextLink, SkipTestConfiguration = (tc => tc.IsRequest) }); return(payloads); }
public void EntryReadingNullUriTest() { EdmModel model = (EdmModel)Microsoft.Test.OData.Utils.Metadata.TestModels.BuildTestModel(); model.Fixup(); NullUriValueTestCase <EntityInstance>[] testCases = new NullUriValueTestCase <EntityInstance>[] { // Setting the read link of an entry // NOTE: in JSON, the 'uri' property will be always omitted from __metadata when the read link is null (and no edit link exists); // in ATOM, the self link will be omitted from the payload new NullUriValueTestCase <EntityInstance> { SetNullUriAction = (instance, uri, testConfig) => instance.RemoveAnnotations(typeof(SelfLinkAnnotation)), }, // Setting the edit link of an entry // NOTE: in JSON, the 'uri' property will be always omitted from __metadata when the edit link is null (and no read link exists); // in ATOM, the link with the 'edit' rel will be omitted from the payload new NullUriValueTestCase <EntityInstance> { SetNullUriAction = (instance, uri, testConfig) => instance.WithEditLink(null), }, // Setting the navigation link of an entry // NOTE: in JSON, the 'uri' property in the __deferred object will have a 'null' value (and we expect an error) // in ATOM, the 'related' link for the navigation property will not have the 'href' property. new NullUriValueTestCase <EntityInstance> { SetNullUriAction = (instance, uri, testConfig) => ((NavigationPropertyInstance)instance.GetProperty("CityHall")).Value = new DeferredLink(), }, // Setting the association link of an entry // NOTE: in JSON, the associationuri property will have a 'null' value (and we expect an error) // in ATOM, the 'relatedlinks' link will not have the 'href' property new NullUriValueTestCase <EntityInstance> { SetNullUriAction = (instance, uri, testConfig) => ((NavigationPropertyInstance)instance.GetProperty("CityHall")).AssociationLink = null, }, // Setting the read link of a stream property // NOTE: in JSON, the 'media_src' property will be omitted from the __mediaresource object. // in ATOM, the 'mediaresource' link of the stream property will be omitted from the payload. new NullUriValueTestCase <EntityInstance> { SetNullUriAction = (instance, uri, testConfig) => ((NamedStreamInstance)instance.GetProperty("Skyline")).SourceLink = null, }, // Setting the edit link of a stream property // NOTE: in JSON, the 'edit_media' property will be omitted from the __mediaresource object. // in ATOM, the 'edit-media' link of the stream property will be omitted from the payload. new NullUriValueTestCase <EntityInstance> { SetNullUriAction = (instance, uri, testConfig) => ((NamedStreamInstance)instance.GetProperty("Skyline")).EditLink = null, }, // Setting the read link of the default stream // NOTE: in JSON, the 'media_src' property will be omitted from the __metadata object. // in ATOM, the <content> element will be omitted from the payload. new NullUriValueTestCase <EntityInstance> { SetNullUriAction = (instance, uri, testConfig) => instance.StreamSourceLink = null, }, // Setting the edit link of the default stream // NOTE: in JSON, the 'edit_media' property will be omitted from the __metadata object. // in ATOM, the edit-media link will be omitted from the payload. new NullUriValueTestCase <EntityInstance> { SetNullUriAction = (instance, uri, testConfig) => instance.StreamEditLink = null, }, }; EntityInstance entry = PayloadBuilder.Entity("TestModel.CityWithMapType") .PrimitiveProperty("Id", 1) .Property(PayloadBuilder.NavigationProperty("CityHall", /*link*/ "http://odata.org/nav-prop").IsCollection(true)) .StreamProperty("Skyline", /*readLink*/ "http://odata.org/stream-read", /*editLink*/ "http://odata.org/stream-edit") .AsMediaLinkEntry() .StreamSourceLink(/*link*/ "http://odata.org/media-read"); this.CombinatorialEngineProvider.RunCombinations( baseUriValues, testCases, this.ReaderTestConfigurationProvider.AtomFormatConfigurations, (baseUriValue, testCase, testConfiguration) => { this.RunNullUriReadingTest(entry, testCase, model, baseUriValue, testConfiguration); }); }
/// <summary> /// Helper method to run a single iteration of the URI reading tests in a specified configuration. /// </summary> /// <typeparam name="T">The type of the payload to read.</typeparam> /// <param name="payloadElement">The payload to read.</param> /// <param name="setExpectedUriAction">An action to set the URI in question on the payload.</param> /// <param name="model">The metadata model.</param> /// <param name="payloadUri">The payload URI for the current iteration.</param> /// <param name="baseUriValue">The base URI value for the current iteration.</param> /// <param name="resolver">The resolver to use.</param> /// <param name="testConfiguration">The reader test configuration.</param> private void RunBaseUriReadingTest <T>( T payloadElement, Action <T, Uri, ReaderTestConfiguration> setExpectedUriAction, IEdmModel model, Uri payloadUri, BaseUriValue baseUriValue, KeyValuePair <Func <Uri, Uri, Uri, Uri>, Uri> resolver, ReaderTestConfiguration testConfiguration, bool runInBatch = false) where T : ODataPayloadElement { this.Assert.IsNull(testConfiguration.MessageReaderSettings.BaseUri, "No base URI expected on reader settings."); ExpectedException expectedException = null; Uri settingsBaseUri = baseUriValue.ReaderSettingBaseUri; // Set the base URI on the message reader settings if specified if (settingsBaseUri != null) { testConfiguration = new ReaderTestConfiguration(testConfiguration); testConfiguration.MessageReaderSettings.BaseUri = settingsBaseUri; } // Create the payload element T clonedPayloadElement = payloadElement.DeepCopy(); setExpectedUriAction(clonedPayloadElement, payloadUri, testConfiguration); if (testConfiguration.Format == ODataFormat.Atom) { XElement xmlRepresentation = this.PayloadElementToXmlConverter.ConvertToXml(clonedPayloadElement); // add an xml:base attribute if specified Uri xmlBaseUri = baseUriValue.XmlBaseUri; if (xmlBaseUri != null) { xmlRepresentation.Add(new XAttribute(XNamespace.Xml.GetName("base"), xmlBaseUri.OriginalString)); } clonedPayloadElement.XmlRepresentation(xmlRepresentation); if (resolver.Value != null) { setExpectedUriAction(clonedPayloadElement, resolver.Value, testConfiguration); } else { // compute the expected URI value for ATOM if (!payloadUri.IsAbsoluteUri) { if (xmlBaseUri != null) { setExpectedUriAction(clonedPayloadElement, new Uri(xmlBaseUri, payloadUri), testConfiguration); } else if (settingsBaseUri != null) { setExpectedUriAction(clonedPayloadElement, new Uri(settingsBaseUri, payloadUri), testConfiguration); } else { // fail for relative URIs without base URI expectedException = ODataExpectedExceptions.ODataException("ODataAtomDeserializer_RelativeUriUsedWithoutBaseUriSpecified", payloadUri.OriginalString); } } } } else { throw new NotSupportedException("Unsupported configuration format: " + testConfiguration.Format.ToString()); } PayloadReaderTestDescriptor testDescriptor = new PayloadReaderTestDescriptor(resolver.Key == null ? this.Settings : this.NoValidatorSettings) { PayloadElement = clonedPayloadElement, PayloadEdmModel = model, ExpectedException = expectedException, UrlResolver = resolver.Key == null ? null : new TestUrlResolver { ResolutionCallback = (baseUri, realPayloadUri) => resolver.Key(payloadUri, baseUri, realPayloadUri) }, SkipTestConfiguration = tc => ODataPayloadElementConfigurationValidator.GetSkipTestConfiguration(payloadElement, ODataPayloadElementConfigurationValidator.AllValidators)(tc), }; if (runInBatch) { // TODO: Batch reader does not enter Exception state upon cross reference error in payload. // Once fixed allow the batch tests to run even for error cases. if (expectedException != null) { return; } if (testConfiguration.IsRequest) { testDescriptor = new PayloadReaderTestDescriptor(testDescriptor) { PayloadElement = PayloadBuilder.BatchRequestPayload( BatchUtils.GetRequestChangeset( new IMimePart[] { testDescriptor.PayloadDescriptor.InRequestOperation( HttpVerb.Put, new ODataUri(ODataUriBuilder.Root(new Uri("http://odata.org/service"))), this.RequestManager, TestMediaTypeUtils.GetDefaultContentType(testDescriptor.PayloadDescriptor.PayloadKind, testConfiguration.Format)) }, this.RequestManager)) .AddAnnotation(new BatchBoundaryAnnotation("bb_request")) }; } else { testDescriptor = new PayloadReaderTestDescriptor(testDescriptor) { PayloadElement = PayloadBuilder.BatchResponsePayload( testDescriptor.PayloadDescriptor.InResponseOperation( 200, this.RequestManager, TestMediaTypeUtils.GetDefaultContentType(testDescriptor.PayloadDescriptor.PayloadKind, testConfiguration.Format))) .AddAnnotation(new BatchBoundaryAnnotation("bb_response")) }; } testConfiguration = new ReaderTestConfiguration(null, testConfiguration.MessageReaderSettings, testConfiguration.IsRequest, testConfiguration.Synchronous, testConfiguration.Version); } testDescriptor.RunTest(testConfiguration); }
public void ReadEntityReferenceLinkTest() { // NOTE: No need for the payload generator here since entity reference links can only appear at the top level. IEnumerable <PayloadReaderTestDescriptor> testDescriptors = TestEntityReferenceLinks.CreateEntityReferenceLinkDescriptors(this.Settings); // make sure this also works with metadata EdmModel model = (EdmModel)Test.OData.Utils.Metadata.TestModels.BuildTestModel(); EdmEntityType cityType = (EdmEntityType)model.FindDeclaredType("TestModel.CityType"); EdmEntitySet citySet = (EdmEntitySet)model.EntityContainersAcrossModels().First().FindEntitySet("Cities"); testDescriptors = testDescriptors.Concat( testDescriptors.Select(td => new PayloadReaderTestDescriptor(td) { PayloadElement = ((DeferredLink)td.PayloadElement.DeepCopy()).ExpectedNavigationProperty(citySet, cityType, "PoliceStation"), PayloadEdmModel = model })); // add some error cases IEnumerable <PayloadReaderTestDescriptor> errorDescriptors = new PayloadReaderTestDescriptor[] { // null link new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.DeferredLink(null).ExpectedNavigationProperty(citySet, cityType, "PoliceStation"), PayloadEdmModel = model, ExpectedResultCallback = tc => new PayloadReaderTestExpectedResult(this.Settings.ExpectedResultSettings) { ExpectedException = ODataExpectedExceptions.ODataException("ODataJsonLightEntityReferenceLinkDeserializer_EntityReferenceLinkUrlCannotBeNull") }, }, // empty link new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.DeferredLink(string.Empty).ExpectedNavigationProperty(citySet, cityType, "PoliceStation"), PayloadEdmModel = model, ExpectedResultCallback = tc => new PayloadReaderTestExpectedResult(this.Settings.ExpectedResultSettings) { ExpectedException = tc.Format == ODataFormat.Json ? null : ODataExpectedExceptions.ODataException("ODataJsonDeserializer_RelativeUriUsedWithoutBaseUriSpecified") }, }, // invalid Uri format new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.DeferredLink("foo-is-not-a-link").ExpectedNavigationProperty(citySet, cityType, "PoliceStation"), PayloadEdmModel = model, ExpectedResultCallback = tc => new PayloadReaderTestExpectedResult(this.Settings.ExpectedResultSettings) { ExpectedException = tc.Format == ODataFormat.Json ? null : ODataExpectedExceptions.ODataException("ODataJsonDeserializer_RelativeUriUsedWithoutBaseUriSpecified") }, }, }; this.CombinatorialEngineProvider.RunCombinations( testDescriptors.Concat(errorDescriptors), this.ReaderTestConfigurationProvider.ExplicitFormatConfigurations, (testDescriptor, testConfiguration) => { if (testConfiguration.Format == ODataFormat.Json && testDescriptor.PayloadEdmModel == null) { // Ignore test cases without model in JSON Light return; } ReaderTestConfiguration testConfigClone = new ReaderTestConfiguration(testConfiguration); if (testConfiguration.Format == ODataFormat.Json) { testConfigClone.MessageReaderSettings.BaseUri = null; } testDescriptor.RunTest(testConfigClone); }); }
public void EntryReadingBaseUriTest() { EdmModel model = (EdmModel)Microsoft.Test.OData.Utils.Metadata.TestModels.BuildTestModel(); model.Fixup(); Action <EntityInstance, Uri, ReaderTestConfiguration>[] setUriActions = new Action <EntityInstance, Uri, ReaderTestConfiguration>[] { // Setting the read link of an entry (instance, uri, testConfig) => { instance.SetAnnotation(new SelfLinkAnnotation(UriToString(uri))); }, // Setting the edit link of an entry (instance, uri, testConfig) => { instance.WithEditLink(UriToString(uri)); }, // Setting the navigation link of an entry (instance, uri, testConfig) => { NavigationPropertyInstance navProperty = instance.GetProperty("CityHall") as NavigationPropertyInstance; this.Assert.IsNotNull(navProperty, "Did not find expected navigation property 'CityHall'."); DeferredLink deferredLink = navProperty.Value as DeferredLink; this.Assert.IsNotNull(deferredLink, "Did not find expected deferred link."); deferredLink.UriString = UriToString(uri); }, // Setting the association link of an entry (instance, uri, testConfig) => { NavigationPropertyInstance navProperty = instance.GetProperty("CityHall") as NavigationPropertyInstance; this.Assert.IsNotNull(navProperty, "Did not find expected navigation property 'CityHall'."); DeferredLink deferredLink = navProperty.AssociationLink as DeferredLink; this.Assert.IsNotNull(deferredLink, "Did not find expected assocation link."); deferredLink.UriString = UriToString(uri); }, // Setting the read link of a stream property (instance, uri, testConfig) => { NamedStreamInstance namedStream = instance.GetProperty("Skyline") as NamedStreamInstance; this.Assert.IsNotNull(namedStream, "Did not find expected stream property 'Skyline'."); namedStream.SourceLink = UriToString(uri); }, // Setting the edit link of a stream property (instance, uri, testConfig) => { NamedStreamInstance namedStream = instance.GetProperty("Skyline") as NamedStreamInstance; this.Assert.IsNotNull(namedStream, "Did not find expected stream property 'Skyline'."); namedStream.EditLink = UriToString(uri); }, // Setting the read link of the default stream (instance, uri, testConfig) => { instance.StreamSourceLink = UriToString(uri); }, // Setting the edit link of the default stream (instance, uri, testConfig) => { instance.StreamEditLink = UriToString(uri); }, // TODO: add tests for operation links (not yet supported in the test infrastructure). }; EntityInstance entry = PayloadBuilder.Entity("TestModel.CityWithMapType") .PrimitiveProperty("Id", 1) .Property(PayloadBuilder.NavigationProperty("CityHall", /*url*/ "http://odata.org/dummy", /*associationUrl*/ "http://odata.org/dummy").IsCollection(true)) .StreamProperty("Skyline", "http://odata.org./dummy") .AsMediaLinkEntry() .StreamSourceLink("http://odata.org/dummy"); this.CombinatorialEngineProvider.RunCombinations( payloadUris, baseUriValues, resolvers, setUriActions, this.ReaderTestConfigurationProvider.AtomFormatConfigurations, (payloadUri, baseUriValue, resolver, setUriAction, testConfiguration) => { this.CombinatorialEngineProvider.RunCombinations( new bool[] { false, true }, runInBatch => { this.RunBaseUriReadingTest(entry, setUriAction, model, payloadUri, baseUriValue, resolver, testConfiguration, runInBatch); }); }); }
public void ReadAssociationLinkTest() { IEdmModel model = TestModels.BuildTestModel(); // TODO: add a payload with a relative association Uri IEnumerable <PayloadReaderTestDescriptor> testDescriptors = new PayloadReaderTestDescriptor[] { // Association link with nav. link new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder .NavigationProperty("NavPropWithAssociationUri", "http://odata.org/NavProp", "http://odata.org/NavPropWithAssociationUri") .IsCollection(true), PayloadEdmModel = model }, // No need to add expanded nav links since those will be generated for us by the payload generator below. }.SelectMany(td => this.PayloadGenerator.GenerateReaderPayloads(td)); // Association links with nav. link IEnumerable <PayloadReaderTestDescriptor> associationLinkTestDescriptors = new PayloadReaderTestDescriptor[] { // Association links without a nav. link // Association link for a singleton nav. property. new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1), PayloadEdmModel = model }, // Association link for a collection nav. property. new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1), PayloadEdmModel = model }, // Association link which is not declared new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).Property( PayloadBuilder.NavigationProperty("Nonexistant", null, "http://odata.org/CityHallLink").IsCollection(true)), PayloadEdmModel = model, ExpectedException = ODataExpectedExceptions.ODataException("ValidationUtils_PropertyDoesNotExistOnType", "Nonexistant", "TestModel.CityType") }, // Association link which is not declared on an open type new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.Entity("TestModel.CityOpenType").Property( PayloadBuilder.NavigationProperty("Nonexistant", null, "http://odata.org/CityHallLink").IsCollection(true)), PayloadEdmModel = model, ExpectedResultCallback = (tc) => new PayloadReaderTestExpectedResult(this.Settings.ExpectedResultSettings) { ExpectedException = (tc.Format == ODataFormat.Json) ? ODataExpectedExceptions.ODataException("ODataJsonLightEntryAndFeedDeserializer_OpenPropertyWithoutValue", "Nonexistant") : ODataExpectedExceptions.ODataException("ValidationUtils_OpenNavigationProperty", "Nonexistant", "TestModel.CityOpenType"), }, }, // Association link which is declared but of wrong kind new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).Property( PayloadBuilder.NavigationProperty("Name", null, "http://odata.org/CityHallLink").IsCollection(true)), PayloadEdmModel = model, ExpectedResultCallback = (tc) => new PayloadReaderTestExpectedResult(this.Settings.ExpectedResultSettings) { ExpectedException = (tc.Format == ODataFormat.Json) ? ODataExpectedExceptions.ODataException("ODataJsonLightEntryAndFeedDeserializer_PropertyWithoutValueWithWrongType", "Name", "Edm.String") : ODataExpectedExceptions.ODataException("ValidationUtils_NavigationPropertyExpected", "Name", "TestModel.CityType", "Structural"), }, }, }; // Generate interesting payloads around the navigation property - this will skip failure cases like request payloads or wrong versions. testDescriptors = testDescriptors.Concat(associationLinkTestDescriptors.SelectMany(td => this.PayloadGenerator.GenerateReaderPayloads(td))); // Add the same cases again, but without skipping interesting configurations. testDescriptors = testDescriptors.Concat(associationLinkTestDescriptors.Select(td => { PayloadReaderTestDescriptor result = new PayloadReaderTestDescriptor(td); var originalResultCallback = result.ExpectedResultCallback; result.ExpectedResultCallback = tc => new PayloadReaderTestExpectedResult(this.Settings.ExpectedResultSettings) { ExpectedException = tc.IsRequest ? null : originalResultCallback == null ? result.ExpectedException : originalResultCallback(tc).ExpectedException, ExpectedPayloadElement = tc.IsRequest ? RemoveAssociationLinkPayloadElementNormalizer.Normalize(result.PayloadElement.DeepCopy()) : result.PayloadElement }; // Setting the ExpectedResultCallback prevents normalizers from being run. result.SkipTestConfiguration = tc => tc.Format == ODataFormat.Json; return(result); })); this.CombinatorialEngineProvider.RunCombinations( testDescriptors, ODataVersionUtils.AllSupportedVersions, this.ReaderTestConfigurationProvider.ExplicitFormatConfigurations, (testDescriptor, maxProtocolVersion, testConfiguration) => { if (maxProtocolVersion < testConfiguration.Version) { return; } testDescriptor.RunTest(testConfiguration.CloneAndApplyMaxProtocolVersion(maxProtocolVersion)); }); }
public void TopLevelPropertiesWithMetadataTest() { IEnumerable <PayloadReaderTestDescriptor> testDescriptors = PayloadReaderTestDescriptorGenerator.CreatePrimitiveValueTestDescriptors(this.Settings); testDescriptors = testDescriptors.Concat(PayloadReaderTestDescriptorGenerator.CreateComplexValueTestDescriptors(this.Settings, true)); testDescriptors = testDescriptors.Concat(PayloadReaderTestDescriptorGenerator.CreateCollectionTestDescriptors(this.Settings, true)); testDescriptors = testDescriptors.Select(collectionTestDescriptor => collectionTestDescriptor.InProperty("propertyName")); testDescriptors = testDescriptors.SelectMany(td => this.PayloadGenerator.GenerateReaderPayloads(td)); // Limit to only top-level property payloads testDescriptors = testDescriptors.Where(td => td.PayloadElement is PropertyInstance); // Add a couple of invalid cases which use a standard model EdmModel model = new EdmModel(); model.ComplexType("UnusedComplexType"); EdmEntityType unusedEntityType = model.EntityType("UnusedEntityType"); unusedEntityType.AddKeys(unusedEntityType.AddStructuralProperty("Id", EdmPrimitiveTypeKind.Int32, isNullable: false)); unusedEntityType.Property("Name", EdmPrimitiveTypeKind.String, isNullable: false); EdmEntityType streamPropertyEntityType = model.EntityType("EntityTypeWithStreamProperty"); streamPropertyEntityType.AddKeys(streamPropertyEntityType.AddStructuralProperty("Id", EdmPrimitiveTypeKind.Int32, isNullable: false)); streamPropertyEntityType.AddStructuralProperty("Video", EdmPrimitiveTypeKind.Stream, isNullable: false); streamPropertyEntityType.Property("NonStreamProperty", EdmPrimitiveTypeKind.Boolean, isNullable: false); EdmEntityType navigationPropertyEntityType = model.EntityType("EntityTypeWithNavigationProperty"); navigationPropertyEntityType.AddKeys(navigationPropertyEntityType.AddStructuralProperty("Id", EdmPrimitiveTypeKind.Int32, isNullable: false)); navigationPropertyEntityType.NavigationProperty("Navigation", streamPropertyEntityType); model.Fixup(); EdmEntityContainer container = model.EntityContainer as EdmEntityContainer; EdmFunction nameFunction = new EdmFunction(container.Namespace, "NameFunctionImport", EdmCoreModel.Instance.GetInt32(false), false /*isBound*/, null, false /*isComposable*/); model.AddElement(nameFunction); container.AddFunctionImport("NameFunctionImport", nameFunction); model.Fixup(); var videoPropertyType = model.GetEntityType("TestModel.EntityTypeWithStreamProperty").Properties().Single(p => p.Name == "Video").Type; var explicitTestDescriptors = new[] { // Non existant type name new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.Property("propertyName", PayloadBuilder.ComplexValue("TestModel.NonExistantType")), PayloadEdmModel = model, ExpectedException = ODataExpectedExceptions.ODataException("ValidationUtils_UnrecognizedTypeName", "TestModel.NonExistantType"), // This test has different meaning in JSON-L (no expected type + non-existent typename) SkipTestConfiguration = (tc) => tc.Format == ODataFormat.Json, }, // Existing type name without namespace new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.Property("propertyName", PayloadBuilder.ComplexValue("UnusedComplexType")), PayloadEdmModel = model, ExpectedException = ODataExpectedExceptions.ODataException("ValidationUtils_UnrecognizedTypeName", "UnusedComplexType"), // This test has different meaning in JSON-L (no expected type + non-existent typename) SkipTestConfiguration = (tc) => tc.Format == ODataFormat.Json, }, // Existing type of wrong kind new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.Property("propertyName", PayloadBuilder.ComplexValue("TestModel.UnusedEntityType")), PayloadEdmModel = model, ExpectedException = ODataExpectedExceptions.ODataException("ValidationUtils_IncorrectValueTypeKind", "TestModel.UnusedEntityType", "Entity"), // This test has different meaning in JSON-L SkipTestConfiguration = (tc) => tc.Format == ODataFormat.Json, }, // A stream is not allowed in a property with a non-stream property kind. new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.Entity("TestModel.EntityTypeWithStreamProperty").StreamProperty("NonStreamProperty", "http://readlink", "http://editlink"), PayloadEdmModel = model, ExpectedResultCallback = tc => new PayloadReaderTestExpectedResult(this.Settings.ExpectedResultSettings) { ExpectedException = tc.Format == ODataFormat.Json ? ODataExpectedExceptions.ODataException("ODataJsonLightResourceDeserializer_PropertyWithoutValueWithWrongType", "NonStreamProperty", "Edm.Boolean") : ODataExpectedExceptions.ODataException("JsonReaderExtensions_UnexpectedNodeDetected", "PrimitiveValue", "StartObject") }, }, // Top-level property of stream type is not allowed new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.PrimitiveProperty("Video", 42).ExpectedPropertyType(videoPropertyType), PayloadEdmModel = model, ExpectedException = ODataExpectedExceptions.ArgumentException("ODataMessageReader_ExpectedPropertyTypeStream"), }, // Top-level deferred navigation property is not allowed new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.PrimitiveProperty("Video", 42).ExpectedPropertyType(streamPropertyEntityType), PayloadEdmModel = model, ExpectedException = ODataExpectedExceptions.ArgumentException("ODataMessageReader_ExpectedPropertyTypeEntityKind"), }, // Top-level expanded navigation property is not allowed new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.PrimitiveProperty("Video", 42).ExpectedPropertyType(streamPropertyEntityType), PayloadEdmModel = model, ExpectedException = ODataExpectedExceptions.ArgumentException("ODataMessageReader_ExpectedPropertyTypeEntityKind"), }, }; testDescriptors = testDescriptors.Concat(explicitTestDescriptors); this.CombinatorialEngineProvider.RunCombinations( testDescriptors, this.ReaderTestConfigurationProvider.ExplicitFormatConfigurations, (testDescriptor, testConfiguration) => { var property = testDescriptor.PayloadElement as PropertyInstance; testDescriptor.RunTest(testConfiguration); }); }
public void NonNullablePropertiesWithNullValuesTest() { IEnumerable <NonNullablePropertyTest> testCases = new NonNullablePropertyTest[] { new NonNullablePropertyTest { Value = null, DataType = EdmCoreModel.Instance.GetString(false), TypeName = "Edm.String" }, new NonNullablePropertyTest { Value = "foo", DataType = EdmCoreModel.Instance.GetString(false), TypeName = "Edm.String" }, new NonNullablePropertyTest { Value = null, DataType = EdmCoreModel.Instance.GetBinary(false), TypeName = "Edm.Binary" }, new NonNullablePropertyTest { Value = new byte[] { 1, 2, 3 }, DataType = EdmCoreModel.Instance.GetBinary(false), TypeName = "Edm.Binary" }, new NonNullablePropertyTest { Value = null, DataType = EdmCoreModel.Instance.GetBoolean(false), TypeName = "Edm.Boolean" }, new NonNullablePropertyTest { Value = true, DataType = EdmCoreModel.Instance.GetBoolean(false), TypeName = "Edm.Boolean" }, new NonNullablePropertyTest { Value = null, DataType = EdmCoreModel.Instance.GetByte(false), TypeName = "Edm.Byte" }, new NonNullablePropertyTest { Value = (byte)1, DataType = EdmCoreModel.Instance.GetByte(false), TypeName = "Edm.Byte" }, new NonNullablePropertyTest { Value = null, DataType = EdmCoreModel.Instance.GetDateTimeOffset(false), TypeName = "Edm.DateTimeOffset" }, new NonNullablePropertyTest { Value = new DateTimeOffset(new DateTime(2011, 08, 31), TimeSpan.Zero), DataType = EdmCoreModel.Instance.GetDateTimeOffset(false), TypeName = "Edm.DateTimeOffset" }, new NonNullablePropertyTest { Value = null, DataType = EdmCoreModel.Instance.GetDecimal(false), TypeName = "Edm.Decimal" }, new NonNullablePropertyTest { Value = (decimal)1.0, DataType = EdmCoreModel.Instance.GetDecimal(false), TypeName = "Edm.Decimal" }, new NonNullablePropertyTest { Value = null, DataType = EdmCoreModel.Instance.GetDouble(false), TypeName = "Edm.Double" }, new NonNullablePropertyTest { Value = (double)1.0, DataType = EdmCoreModel.Instance.GetDouble(false), TypeName = "Edm.Double" }, new NonNullablePropertyTest { Value = null, DataType = EdmCoreModel.Instance.GetSingle(false), TypeName = "Edm.Single" }, new NonNullablePropertyTest { Value = (float)1.0, DataType = EdmCoreModel.Instance.GetSingle(false), TypeName = "Edm.Single" }, new NonNullablePropertyTest { Value = null, DataType = EdmCoreModel.Instance.GetSByte(false), TypeName = "Edm.SByte" }, new NonNullablePropertyTest { Value = (sbyte)1, DataType = EdmCoreModel.Instance.GetSByte(false), TypeName = "Edm.SByte" }, new NonNullablePropertyTest { Value = null, DataType = EdmCoreModel.Instance.GetInt16(false), TypeName = "Edm.Int16" }, new NonNullablePropertyTest { Value = (Int16)1, DataType = EdmCoreModel.Instance.GetInt16(false), TypeName = "Edm.Int16" }, new NonNullablePropertyTest { Value = null, DataType = EdmCoreModel.Instance.GetInt32(false), TypeName = "Edm.Int32" }, new NonNullablePropertyTest { Value = (Int32)1, DataType = EdmCoreModel.Instance.GetInt32(false), TypeName = "Edm.Int32" }, new NonNullablePropertyTest { Value = null, DataType = EdmCoreModel.Instance.GetInt64(false), TypeName = "Edm.Int64" }, new NonNullablePropertyTest { Value = (Int64)1, DataType = EdmCoreModel.Instance.GetInt64(false), TypeName = "Edm.Int64" }, new NonNullablePropertyTest { Value = null, DataType = EdmCoreModel.Instance.GetGuid(false), TypeName = "Edm.Guid" }, new NonNullablePropertyTest { Value = Guid.NewGuid(), DataType = EdmCoreModel.Instance.GetGuid(false), TypeName = "Edm.Guid" }, }; IEnumerable <PayloadReaderTestDescriptor> testDescriptors = testCases.Select(testCase => new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.PrimitiveValue(testCase.Value).WithTypeAnnotation(testCase.DataType), PayloadEdmModel = new EdmModel().Fixup(), ExpectedException = testCase.Value == null ? ODataExpectedExceptions.ODataException("ReaderValidationUtils_NullNamedValueForNonNullableType", "value", testCase.TypeName) : null, }); testDescriptors = testDescriptors.Select(td => td.InProperty("propertyName")); testDescriptors = testDescriptors.SelectMany(td => this.PayloadGenerator.GenerateReaderPayloads(td)); this.CombinatorialEngineProvider.RunCombinations( testDescriptors, this.ReaderTestConfigurationProvider.ExplicitFormatConfigurations, (testDescriptor, testConfiguration) => { if (!(testDescriptor.PayloadElement is PrimitiveProperty) && testDescriptor.ExpectedException != null) { testDescriptor = new PayloadReaderTestDescriptor(testDescriptor); testDescriptor.ExpectedException = ODataExpectedExceptions.ODataException( "ReaderValidationUtils_NullNamedValueForNonNullableType", "propertyName", testDescriptor.ExpectedException.ExpectedMessage.Arguments.ElementAt(1)); } var property = testDescriptor.PayloadElement as PropertyInstance; testDescriptor.RunTest(testConfiguration); }); }
public void CollectionWithoutExpectedTypeAndWithMetadataTest() { // For now only top-level property can do this. // TODO: Once we have open properties, these test cases apply to those as well, then probably move these to the top-level property // tests and share them from the open properties test, or possible keep both here. IEnumerable <PayloadReaderTestDescriptor> testDescriptors = this.CreateCollectionPayloadsWithMetadata(true); testDescriptors = testDescriptors.Concat(this.CreateInvalidCollectionsWithTypeNames(false)); EdmModel model = new EdmModel(); EdmComplexType itemComplexType = model.ComplexType("ItemComplexType").Property("stringProperty", EdmPrimitiveTypeKind.String); model = model.Fixup(); testDescriptors = testDescriptors.Concat(new[] { // No expected type specified, the one in the payload should be enough new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.PrimitiveMultiValue(EntityModelUtils.GetCollectionTypeName("Edm.String")), PayloadEdmModel = model, }, new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.ComplexMultiValue(EntityModelUtils.GetCollectionTypeName("TestModel.ItemComplexType")), PayloadEdmModel = model, }, // Verify that the item type is inherited from the collection to its items if the item doesn't specify the type new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.ComplexMultiValue(EntityModelUtils.GetCollectionTypeName("TestModel.ItemComplexType")) .Item(PayloadBuilder .ComplexValue() .PrimitiveProperty("stringProperty", "test") .WithTypeAnnotation(itemComplexType) .AddAnnotation(new SerializationTypeNameTestAnnotation() { TypeName = null })), // Add item which does not have the type name PayloadEdmModel = model }, new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.ComplexMultiValue(EntityModelUtils.GetCollectionTypeName("TestModel.ItemComplexType")) .Item(PayloadBuilder .ComplexValue("TestModel.ItemComplexType") .PrimitiveProperty("stringProperty", "test") .WithTypeAnnotation(itemComplexType)) // Add an item which does have the type name .Item(PayloadBuilder .ComplexValue() .PrimitiveProperty("stringProperty", "test") .WithTypeAnnotation(itemComplexType) .AddAnnotation(new SerializationTypeNameTestAnnotation() { TypeName = null })), // Add item which does not have the type name PayloadEdmModel = model } }); // Wrap the value in a top-level property without expected type (can't use the .InProperty here, since that would put the expected type on it) testDescriptors = testDescriptors.Select(td => new PayloadReaderTestDescriptor(td) { PayloadElement = PayloadBuilder.Property("propertyName", td.PayloadElement) }); // Fill in type names for expected result from the type annotations testDescriptors = testDescriptors.Select(td => { td.ExpectedResultNormalizers.Add(tc => FillTypeNamesFromTypeAnnotationsPayloadElementVisitor.Visit); return(td); }); this.CombinatorialEngineProvider.RunCombinations( testDescriptors, // The version dependent behavior tests are implemented in the format specific tests. this.ReaderTestConfigurationProvider.ExplicitFormatConfigurations, (testDescriptor, testConfiguration) => { testDescriptor.PayloadNormalizers.Add((tc) => tc.Format == ODataFormat.Json ? ReplaceExpectedTypeWithContextUriVisitor.VisitPayload : (Func <ODataPayloadElement, ODataPayloadElement>)null); var property = testDescriptor.PayloadElement as PropertyInstance; testDescriptor.RunTest(testConfiguration); }); }
public Idle Build(PayloadBuilder builder) { return(Idle.Default); }
public Direction Build(PayloadBuilder builder) { return(Direction.Create(type)); }
public void ReadActionsAndFunctionsTest() { IEdmModel model = Microsoft.Test.OData.Utils.Metadata.TestModels.BuildTestModel(); IEnumerable <ServiceOperationDescriptor> operations = new ServiceOperationDescriptor[] { new ServiceOperationDescriptor { IsAction = true, Metadata = "http://odata.org/service/$metadata#operation", Target = "http://odata.org/Target" }, new ServiceOperationDescriptor { IsAction = true, Metadata = "http://odata.org/service/$metadata#operation", Title = "Title", Target = "http://odata.org/Target2" }, }; operations = operations.Concat(operations.Select(o => (ServiceOperationDescriptor) new ServiceOperationDescriptor { IsFunction = true, Metadata = o.Metadata, Title = o.Title, Target = o.Target })); IEnumerable <PayloadReaderTestDescriptor> testDescriptors = operations.Select(o => { EntityInstance entityInstance = PayloadBuilder.Entity("TestModel.CityType"); entityInstance.Add(o); return(new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = entityInstance, PayloadEdmModel = model }); }); // Add couple more handcrafted cases testDescriptors.Concat(new PayloadReaderTestDescriptor[] { // Duplicate action - different targets new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.Entity("TestModel.CityType") .OperationDescriptor(new ServiceOperationDescriptor { IsAction = true, Metadata = "http://odata.org/service/$metadata#action", Target = "http://odata.org/service/action" }) .OperationDescriptor(new ServiceOperationDescriptor { IsAction = true, Metadata = "http://odata.org/service/$metadata#action", Target = "http://odata.org/service/action2" }), PayloadEdmModel = model }, // Duplicate action - same targets // same targets in a metadata - allowed new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.Entity("TestModel.CityType") .OperationDescriptor(new ServiceOperationDescriptor { IsAction = true, Metadata = "http://odata.org/service/$metadata#action", Target = "http://odata.org/service/action" }) .OperationDescriptor(new ServiceOperationDescriptor { IsAction = true, Metadata = "http://odata.org/service/$metadata#action", Target = "http://odata.org/service/action" }), PayloadEdmModel = model }, // Duplicate function - different targets and titles new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.Entity("TestModel.CityType") .OperationDescriptor(new ServiceOperationDescriptor { IsFunction = true, Metadata = "http://odata.org/service/$metadata#function", Target = "http://odata.org/service/function", Title = "Function 1" }) .OperationDescriptor(new ServiceOperationDescriptor { IsFunction = true, Metadata = "http://odata.org/service/$metadata#function", Target = "http://odata.org/service/function2", Title = "Function 2" }), PayloadEdmModel = model }, // Duplicate function - same targets and titles // same targets in a metadata - allowed new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.Entity("TestModel.CityType") .OperationDescriptor(new ServiceOperationDescriptor { IsFunction = true, Metadata = "http://odata.org/service/$metadata#function", Target = "http://odata.org/service/function", Title = "Function 1" }) .OperationDescriptor(new ServiceOperationDescriptor { IsFunction = true, Metadata = "http://odata.org/service/$metadata#function", Target = "http://odata.org/service/function", Title = "Function 1" }), PayloadEdmModel = model }, // Function and Action with the same name (ODL doesn't validate this case) new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.Entity("TestModel.CityType") .OperationDescriptor(new ServiceOperationDescriptor { IsAction = true, Metadata = "http://odata.org/service/$metadata#operation", Target = "http://odata.org/service/action", Title = "Action" }) .OperationDescriptor(new ServiceOperationDescriptor { IsFunction = true, Metadata = "http://odata.org/service/$metadata#operation", Target = "http://odata.org/service/function", Title = "Function" }), PayloadEdmModel = model }, }); // Generate interesting payloads for the EntityInstance with actions/functions // TODO: Fix places where we've lost JsonVerbose coverage to add JsonLight testDescriptors = testDescriptors.SelectMany(td => this.PayloadGenerator.GenerateReaderPayloads(td)); this.CombinatorialEngineProvider.RunCombinations( testDescriptors, ODataVersionUtils.AllSupportedVersions, this.ReaderTestConfigurationProvider.ExplicitFormatConfigurations.Where(tc => false), (testDescriptor, maxProtocolVersion, testConfiguration) => { if (maxProtocolVersion < testConfiguration.Version) { // This would fail since the DSV > MPV. return; } // In requests or if MPV < V3 we don't expect the operations to be read. if (testConfiguration.IsRequest) { testDescriptor = new PayloadReaderTestDescriptor(testDescriptor); testDescriptor.ExpectedResultNormalizers.Add(tc => RemoveOperationsNormalizer.Normalize); } testDescriptor.RunTest(testConfiguration.CloneAndApplyMaxProtocolVersion(maxProtocolVersion)); }); }
public void PrimitiveTopLevelValueWithDisabledTypeConversionTest() { IEdmModel testModel = TestModels.BuildTestModel(); IEnumerable <ReaderContentTypeTestDescriptor> testDescriptors = primitiveValueConversionTestCases .SelectMany(testCase => TestValues.PrimitiveTypes .SelectMany(nonNullableTargetType => new bool[] { true, false } .SelectMany(includeNullableType => new bool[] { true, false } .Select(useExpectedType => { PrimitiveDataType targetType = EntityModelUtils.GetPrimitiveEdmType(nonNullableTargetType); if (includeNullableType) { targetType = targetType.Nullable(); } ODataPayloadElement resultValue; if (nonNullableTargetType == typeof(byte[])) { resultValue = testCase.ConversionValues.Where(cv => cv.ClrValue.GetType() == typeof(byte[])).Single().DeepCopy(); } else { resultValue = testCase.ConversionValues.Where(cv => cv.ClrValue.GetType() == typeof(string)).Single().DeepCopy(); } ODataPayloadElement payloadElement; if (useExpectedType) { payloadElement = PayloadBuilder.PrimitiveValue(testCase.SourceString).ExpectedPrimitiveValueType(targetType); } else { payloadElement = PayloadBuilder.PrimitiveValue(testCase.SourceString); } return(new ReaderContentTypeTestDescriptor(this.Settings) { PayloadElement = payloadElement, ExpectedResultPayloadElement = (testConfig) => resultValue, ContentType = ComputeContentType(nonNullableTargetType), ExpectedFormat = ODataFormat.RawValue, }); })))); // add variants that use a metadata provider testDescriptors = testDescriptors.Concat(testDescriptors.Select(td => new ReaderContentTypeTestDescriptor(td) { PayloadEdmModel = testModel })); this.CombinatorialEngineProvider.RunCombinations( testDescriptors, // restricting the set of default format configurations to limiti runtime of the tests this.ReaderTestConfigurationProvider.DefaultFormatConfigurations.Where(tc => tc.MessageReaderSettings.EnableMessageStreamDisposal && !tc.IsRequest), (testDescriptor, testConfig) => { testConfig = new ReaderTestConfiguration(testConfig); testConfig.MessageReaderSettings.EnablePrimitiveTypeConversion = false; testDescriptor.RunTest(testConfig); }); }
private static ODataPayloadElement CreatePayloadElement(IEdmModel model, ODataPayloadKind payloadKind, ReaderTestConfiguration testConfig) { IEdmEntitySet citySet = model.EntityContainer.FindEntitySet("Cities"); IEdmEntityType cityType = model.EntityTypes().Single(e => e.Name == "CityType"); IEdmProperty cityNameProperty = cityType.Properties().Single(e => e.Name == "Name"); IEdmNavigationProperty policeStationNavProp = cityType.NavigationProperties().Single(e => e.Name == "PoliceStation"); IEdmOperationImport primitiveCollectionResultOperation = model.EntityContainer.FindOperationImports("PrimitiveCollectionResultOperation").Single(); IEdmOperationImport serviceOp1 = model.EntityContainer.FindOperationImports("ServiceOperation1").Single(); bool isRequest = testConfig.IsRequest; bool isJsonLightRequest = isRequest && testConfig.Format == ODataFormat.Json; switch (payloadKind) { case ODataPayloadKind.ResourceSet: { return(PayloadBuilder.EntitySet().WithTypeAnnotation(cityType).ExpectedEntityType(cityType, citySet)); } case ODataPayloadKind.Resource: { return(PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).WithTypeAnnotation(cityType).ExpectedEntityType(cityType, citySet)); } case ODataPayloadKind.Property: return(PayloadBuilder.PrimitiveProperty(isJsonLightRequest ? string.Empty : null, "SomeCityValue").ExpectedProperty(cityType, "Name")); case ODataPayloadKind.EntityReferenceLink: return(PayloadBuilder.DeferredLink("http://odata.org/entityreferencelink").ExpectedNavigationProperty(citySet, cityType, "PoliceStation")); case ODataPayloadKind.EntityReferenceLinks: return(PayloadBuilder.LinkCollection().Item(PayloadBuilder.DeferredLink("http://odata.org/entityreferencelink")).ExpectedNavigationProperty((EdmEntitySet)citySet, (EdmEntityType)cityType, "CityHall")); case ODataPayloadKind.Value: return(PayloadBuilder.PrimitiveValue("PrimitiveValue")); case ODataPayloadKind.BinaryValue: return(PayloadBuilder.PrimitiveValue(new byte[] { 0, 0, 1, 1 })); case ODataPayloadKind.Collection: return(PayloadBuilder.PrimitiveCollection().CollectionName(null).ExpectedFunctionImport((EdmOperationImport)primitiveCollectionResultOperation)); case ODataPayloadKind.ServiceDocument: Debug.Assert(!isRequest, "Not supported in requests."); return(new ServiceDocumentInstance().Workspace(PayloadBuilder.Workspace())); case ODataPayloadKind.MetadataDocument: Debug.Assert(!isRequest, "Not supported in requests."); throw new NotImplementedException(); case ODataPayloadKind.Error: Debug.Assert(!isRequest, "Not supported in requests."); return(PayloadBuilder.Error("ErrorCode")); case ODataPayloadKind.Parameter: // build parameter payload based on model definition var parameterPayload = new ComplexInstance(null, false); ODataPayloadElement a = PayloadBuilder.PrimitiveValue(123).WithTypeAnnotation(EdmCoreModel.Instance.GetInt32(false)); ODataPayloadElement b = PayloadBuilder.PrimitiveValue("stringvalue").WithTypeAnnotation(EdmCoreModel.Instance.GetString(false)); PrimitiveProperty parametera = new PrimitiveProperty("a", "Edm.Integer", ((PrimitiveValue)a).ClrValue); PrimitiveProperty parameterb = new PrimitiveProperty("b", "Edm.String", ((PrimitiveValue)b).ClrValue); parameterPayload.Add(parametera); parameterPayload.Add(parameterb); parameterPayload.ExpectedFunctionImport((EdmOperationImport)serviceOp1); return(parameterPayload); case ODataPayloadKind.Unsupported: // fall through default: throw new NotSupportedException(); } }
private IEnumerable <PayloadWriterTestDescriptor <ODataPayloadElement> > CreateFeedValidatorDescriptors(IEdmModel model) { var cityType = model.EntityTypes().Single(type => type.FullName() == "TestModel.CityType"); var personType = model.EntityTypes().Single(type => type.FullName() == "TestModel.Person"); var employeeType = model.EntityTypes().Single(type => type.FullName() == "TestModel.Employee"); var testCases = new[] { new { Description = "Homogenous collection (no inheritance)", Feed = (ODataPayloadElement)PayloadBuilder.EntitySet().WithDefaultAtomIDAnnotation().WithTypeAnnotation(personType) .Append(PayloadBuilder.Entity("TestModel.Person") .PrimitiveProperty("Id", 1).WithTypeAnnotation(personType)) .Append(PayloadBuilder.Entity("TestModel.Person") .PrimitiveProperty("Id", 2).WithTypeAnnotation(personType)), ExpectedException = (ExpectedException)null, Model = model }, new { Description = "Homogenous collection (inheritance, base type first)", Feed = (ODataPayloadElement)PayloadBuilder.EntitySet().WithDefaultAtomIDAnnotation().WithTypeAnnotation(personType) .Append(PayloadBuilder.Entity("TestModel.Person") .PrimitiveProperty("Id", 1).WithTypeAnnotation(personType)) .Append(PayloadBuilder.Entity("TestModel.Employee") .PrimitiveProperty("Id", 2).WithTypeAnnotation(employeeType)), ExpectedException = (ExpectedException)null, Model = model }, new { Description = "Homogenous collection (inheritance, derived type first)", Feed = (ODataPayloadElement)PayloadBuilder.EntitySet().WithDefaultAtomIDAnnotation().WithTypeAnnotation(personType) .Append(PayloadBuilder.Entity("TestModel.Employee") .PrimitiveProperty("Id", 1).WithTypeAnnotation(employeeType)) .Append(PayloadBuilder.Entity("TestModel.Person") .PrimitiveProperty("Id", 2).WithTypeAnnotation(personType)), ExpectedException = (ExpectedException)null, Model = model }, new { Description = "Heterogeneous collection", Feed = (ODataPayloadElement)PayloadBuilder.EntitySet().WithDefaultAtomIDAnnotation().WithTypeAnnotation(personType) .Append(PayloadBuilder.Entity("TestModel.Person") .PrimitiveProperty("Id", 1).WithTypeAnnotation(personType)) .Append(PayloadBuilder.Entity("TestModel.CityType") .PrimitiveProperty("Id", 2).WithTypeAnnotation(cityType)), ExpectedException = ODataExpectedExceptions.ODataException("ResourceSetWithoutExpectedTypeValidator_IncompatibleTypes", "TestModel.CityType", "TestModel.Person"), Model = model }, new { Description = "Heterogeneous collection (no model)", Feed = (ODataPayloadElement)PayloadBuilder.EntitySet().WithDefaultAtomIDAnnotation() .Append(PayloadBuilder.Entity("TestModel.Person") .PrimitiveProperty("Id", 1)) .Append(PayloadBuilder.Entity("TestModel.CityType") .PrimitiveProperty("Id", 2)), ExpectedException = (ExpectedException)null, Model = (IEdmModel)null }, }; // Create the tests for a top-level feed return(testCases.Select(testCase => new PayloadWriterTestDescriptor <ODataPayloadElement>(this.Settings, testCase.Feed) { DebugDescription = testCase.Description, Model = testCase.Model, PayloadDescriptor = new PayloadTestDescriptor() { DebugDescription = testCase.Description, PayloadElement = testCase.Feed, PayloadEdmModel = testCase.Model, SkipTestConfiguration = tc => testCase.Model == null && tc.Format == ODataFormat.Json, }, ExpectedResultCallback = (tc) => { return new PayloadWriterTestExpectedResults(this.ExpectedResultSettings) { ExpectedPayload = testCase.Feed, ExpectedException2 = testCase.ExpectedException, }; } })); }
public void EntityReferenceLinksReaderAtomTest() { const string link1String = "http://odata.org/deferred1"; const string link2String = "http://odata.org/deferred2"; const string nextString = "http://odata.org/next"; DeferredLink link1 = PayloadBuilder.DeferredLink(link1String); DeferredLink link2 = PayloadBuilder.DeferredLink(link2String); #region Extra attributes on the <feed> element var linksElementPayloads = new[] { // extra attributes on <links> element without content new { PayloadElement = PayloadBuilder.LinkCollection(), Template = "<feed {0} />", }, // extra attributes on <m:count> element new { PayloadElement = PayloadBuilder.LinkCollection().InlineCount(1), Template = "<feed><m:count {0}>1</m:count></feed>", }, // extra attributes on <d:next> element new { PayloadElement = PayloadBuilder.LinkCollection().NextLink("http://odata.org/next"), Template = "<feed><d:next {0}>http://odata.org/next</d:next></feed>", }, }; string[] attributes = new string[] { "foo='bar'", "m:foo='bar'", "foo=''", "lang='invalid'", }; IEnumerable <PayloadReaderTestDescriptor> testDescriptors = linksElementPayloads.SelectMany(linkPayload => attributes.Select(attribute => { var payloadElement = linkPayload.PayloadElement.DeepCopy(); string xmlRep = string.Format(CultureInfo.InvariantCulture, linkPayload.Template, attribute); payloadElement = payloadElement.XmlRepresentation(xmlRep); return(new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = payloadElement, }); })); #endregion Extra attributes on the <links> element #region Extra padding between the elements var extraPaddingPayloads = new[] { new { PayloadElement = PayloadBuilder.LinkCollection(), Template = "<feed>{0}</feed>", }, new { PayloadElement = PayloadBuilder.LinkCollection().InlineCount(1), Template = "<feed>{0}<m:count>1</m:count></feed>", }, new { PayloadElement = PayloadBuilder.LinkCollection().InlineCount(1), Template = "<feed><m:count>1</m:count>{0}</feed>", }, new { PayloadElement = PayloadBuilder.LinkCollection().NextLink(nextString), Template = "<feed>{0}<d:next>http://odata.org/next</d:next></feed>", }, new { PayloadElement = PayloadBuilder.LinkCollection().NextLink(nextString), Template = "<feed><d:next>http://odata.org/next</d:next>{0}</feed>", }, new { PayloadElement = PayloadBuilder.LinkCollection().InlineCount(1).NextLink(nextString), Template = "<feed><m:count>1</m:count>{0}<d:next>http://odata.org/next</d:next></feed>", }, new { PayloadElement = PayloadBuilder.LinkCollection().Item(link1).InlineCount(1).NextLink(nextString), Template = "<feed><m:count>1</m:count>{0}<m:ref id =\"" + link1String + "\"/><d:next>" + nextString + "</d:next></feed>", }, new { PayloadElement = PayloadBuilder.LinkCollection().Item(link1).InlineCount(1).NextLink(nextString), Template = "<feed><m:count>1</m:count><m:ref id=\"" + link1String + "\"/>{0}<d:next>" + nextString + "</d:next></feed>", }, new { PayloadElement = PayloadBuilder.LinkCollection().Item(link1).Item(link2).InlineCount(2).NextLink(nextString), Template = "<feed><m:count>2</m:count><m:ref id=\"" + link1String + "\"/>{0}<m:ref id=\"" + link2String + "\"/><d:next>" + nextString + "</d:next></feed>", }, }; string[] xmlPaddingToIgnore = new string[] { string.Empty, // Nothing " \r\n\t", // Whitespace only "<!--s--> <?value?>", // Insignificant nodes "some text <![CDATA[cdata]]>", // Significant nodes to be ignored "<foo xmlns=''/>", // Element in no namespace "<c:foo xmlns:c='ref' attr='1'><c:child/>text</c:foo>", // Element in custom namespace "<d:properties/>", // Element in data namespace (should be ignored as well) "<entry/>", // Element in atom namespace (should also be ignored) }; IEnumerable <PayloadReaderTestDescriptor> extraPaddingTestDescriptors = extraPaddingPayloads.SelectMany(extraPaddingPayload => xmlPaddingToIgnore.Select(xmlPadding => { var payloadElement = extraPaddingPayload.PayloadElement.DeepCopy(); string xmlRep = string.Format(CultureInfo.InvariantCulture, extraPaddingPayload.Template, xmlPadding); payloadElement = payloadElement.XmlRepresentation(xmlRep); return(new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = payloadElement, }); })); testDescriptors = testDescriptors.Concat(extraPaddingTestDescriptors); #endregion Extra padding between the elements #region Extra elements in the <feed> content LinkCollection links = PayloadBuilder.LinkCollection() .InlineCount(2) .Item(PayloadBuilder.DeferredLink(link1String)) .Item(PayloadBuilder.DeferredLink(link2String)) .NextLink(nextString); XElement ref1Element = new XElement(TestAtomConstants.ODataMetadataXNamespace + TestAtomConstants.ODataRefElementName); ref1Element.SetAttributeValue(TestAtomConstants.AtomIdElementName, link1String); XElement ref2Element = new XElement(TestAtomConstants.ODataMetadataXNamespace + TestAtomConstants.ODataRefElementName); ref1Element.SetAttributeValue(TestAtomConstants.AtomIdElementName, link2String); XElement xmlRepresentation = new XElement(TestAtomConstants.AtomXNamespace + TestAtomConstants.AtomFeedElementName, new XElement(TestAtomConstants.ODataMetadataXNamespace + TestAtomConstants.ODataCountElementName, "2"), ref1Element, ref2Element, new XElement(TestAtomConstants.ODataXNamespace + TestAtomConstants.ODataNextLinkElementName, nextString)); XElement[] extraElements = new XElement[] { new XElement(XName.Get("foo"), "bar"), new XElement(XName.Get("foo"), new XElement(XName.Get("bar"))), new XElement(XName.Get("foo"), new XAttribute(XName.Get("bar"), "attribute-value")), new XElement(TestAtomConstants.ODataMetadataXNamespace + "foo", "bar"), new XElement(TestAtomConstants.ODataMetadataXNamespace + "foo", new XElement(TestAtomConstants.ODataMetadataXNamespace + "bar")), new XElement(XName.Get("foo"), new XAttribute(TestAtomConstants.ODataMetadataXNamespace + "bar", "attribute-value")), // "Ref" element in the OData metadaata namespace, should be ignored, "ref" is expected new XElement(TestAtomConstants.ODataMetadataXNamespace + "Ref"), // "uri" element in the OData namespace, should be ignored, OData metadata namespace is expected new XElement(TestAtomConstants.ODataXNamespace + "ref"), }; IEnumerable <PayloadReaderTestDescriptor> extraElementTestDescriptors = extraElements.SelectMany(extraElement => { return(InjectElement(extraElement, xmlRepresentation).Select(linksWithInjectedElement => new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = links.DeepCopy().XmlRepresentation(linksWithInjectedElement), } )); }); testDescriptors = testDescriptors.Concat(extraElementTestDescriptors); #endregion Extra elements in the <links> content #region Various payload orders for an error element links = PayloadBuilder.LinkCollection() .InlineCount(1) .Item(PayloadBuilder.DeferredLink(link1String)) .NextLink(nextString); ref1Element = new XElement(TestAtomConstants.ODataMetadataXNamespace + TestAtomConstants.ODataRefElementName); ref1Element.SetAttributeValue(TestAtomConstants.AtomIdElementName, link1String); xmlRepresentation = new XElement(TestAtomConstants.AtomXNamespace + TestAtomConstants.AtomFeedElementName, new XElement(TestAtomConstants.ODataMetadataXNamespace + TestAtomConstants.ODataCountElementName, "1"), ref1Element, new XElement(TestAtomConstants.ODataXNamespace + TestAtomConstants.ODataNextLinkElementName, nextString)); IEnumerable <PayloadReaderTestDescriptor> payloadOrderTestDescriptors = GeneratePayloadOrders(xmlRepresentation).Select(xmlRep => new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = links.DeepCopy().XmlRepresentation(xmlRep), } ); testDescriptors = testDescriptors.Concat(payloadOrderTestDescriptors); #endregion Various payload orders for an error element this.CombinatorialEngineProvider.RunCombinations( testDescriptors, this.ReaderTestConfigurationProvider.AtomFormatConfigurations, (testDescriptor, testConfiguration) => { testDescriptor.RunTest(testConfiguration); }); }
public void ReadODataOperationTest() { IEdmModel model = Test.OData.Utils.Metadata.TestModels.BuildTestModel(); IEdmEntityContainer container = model.FindEntityContainer("DefaultContainer"); IEdmEntitySet cities = container.FindEntitySet("Cities"); IEdmType cityType = model.FindType("TestModel.CityType"); var testCases = new[] { new { DebugDescription = "Single operation without title and target", Json = "\"#TestModel.PrimitiveResultOperation\":{}", ExpectedServiceOperationDescriptor = new[] { new ServiceOperationDescriptor { IsAction = true, Metadata = "http://odata.org/test/$metadata#TestModel.PrimitiveResultOperation", Title = "TestModel.PrimitiveResultOperation", Target = "http://odata.org/test/Cities(1)/TestModel.PrimitiveResultOperation" } } }, new { DebugDescription = "Single operation with title", Json = "\"#TestModel.PrimitiveResultOperation\":{\"title\":\"PrimitiveResultOperation\"}", ExpectedServiceOperationDescriptor = new[] { new ServiceOperationDescriptor { IsAction = true, Metadata = "http://odata.org/test/$metadata#TestModel.PrimitiveResultOperation", Title = "PrimitiveResultOperation", Target = "http://odata.org/test/Cities(1)/TestModel.PrimitiveResultOperation" } } }, new { DebugDescription = "Single operation with target", Json = "\"#TestModel.PrimitiveResultOperation\":{\"target\":\"http://odata.org/test/PrimitiveResultOperation\"}", ExpectedServiceOperationDescriptor = new[] { new ServiceOperationDescriptor { IsAction = true, Metadata = "http://odata.org/test/$metadata#TestModel.PrimitiveResultOperation", Title = "TestModel.PrimitiveResultOperation", Target = "http://odata.org/test/PrimitiveResultOperation" } } }, new { DebugDescription = "Single operation with title and target", Json = "\"#TestModel.PrimitiveResultOperation\":{\"title\":\"PrimitiveResultOperation\", \"target\":\"http://odata.org/test/PrimitiveResultOperation\"}", ExpectedServiceOperationDescriptor = new[] { new ServiceOperationDescriptor { IsAction = true, Metadata = "http://odata.org/test/$metadata#TestModel.PrimitiveResultOperation", Title = "PrimitiveResultOperation", Target = "http://odata.org/test/PrimitiveResultOperation" } } }, new { DebugDescription = "Single operation with 2 targets", Json = "\"#TestModel.PrimitiveResultOperation\":[{\"target\":\"http://odata.org/test/PrimitiveResultOperation1\"},{\"target\":\"http://odata.org/test/PrimitiveResultOperation2\"}]", ExpectedServiceOperationDescriptor = new[] { new ServiceOperationDescriptor { IsAction = true, Metadata = "http://odata.org/test/$metadata#TestModel.PrimitiveResultOperation", Title = "TestModel.PrimitiveResultOperation", Target = "http://odata.org/test/PrimitiveResultOperation1" }, new ServiceOperationDescriptor { IsAction = true, Metadata = "http://odata.org/test/$metadata#TestModel.PrimitiveResultOperation", Title = "TestModel.PrimitiveResultOperation", Target = "http://odata.org/test/PrimitiveResultOperation2" } } }, new { DebugDescription = "Single operation with 2 targets and 2 titles", Json = "\"#TestModel.PrimitiveResultOperation\":[{\"title\":\"title1\",\"target\":\"http://odata.org/test/PrimitiveResultOperation1\"},{\"title\":\"title2\",\"target\":\"http://odata.org/test/PrimitiveResultOperation2\"}]", ExpectedServiceOperationDescriptor = new[] { new ServiceOperationDescriptor { IsAction = true, Metadata = "http://odata.org/test/$metadata#TestModel.PrimitiveResultOperation", Title = "title1", Target = "http://odata.org/test/PrimitiveResultOperation1" }, new ServiceOperationDescriptor { IsAction = true, Metadata = "http://odata.org/test/$metadata#TestModel.PrimitiveResultOperation", Title = "title2", Target = "http://odata.org/test/PrimitiveResultOperation2" } } }, new { DebugDescription = "Two operations, one without target or title, the other with with 2 targets", Json = "\"#TestModel.PrimitiveResultOperation\":[{\"target\":\"http://odata.org/test/PrimitiveResultOperation1\"},{\"target\":\"http://odata.org/test/PrimitiveResultOperation2\"}]," + "\"#TestModel.ComplexResultOperation\":{}", ExpectedServiceOperationDescriptor = new[] { new ServiceOperationDescriptor { IsAction = true, Metadata = "http://odata.org/test/$metadata#TestModel.PrimitiveResultOperation", Title = "TestModel.PrimitiveResultOperation", Target = "http://odata.org/test/PrimitiveResultOperation1" }, new ServiceOperationDescriptor { IsAction = true, Metadata = "http://odata.org/test/$metadata#TestModel.PrimitiveResultOperation", Title = "TestModel.PrimitiveResultOperation", Target = "http://odata.org/test/PrimitiveResultOperation2" }, new ServiceOperationDescriptor { IsAction = true, Metadata = "http://odata.org/test/$metadata#TestModel.ComplexResultOperation", Title = "TestModel.ComplexResultOperation", Target = "http://odata.org/test/Cities(1)/TestModel.ComplexResultOperation" }, } }, new { DebugDescription = "Two operations, one with target and title, the other with 2 targets and 1 title", Json = "\"#TestModel.PrimitiveResultOperation\":[{\"title\":\"PrimitiveResultOperation\",\"target\":\"http://odata.org/test/PrimitiveResultOperation1\"},{\"target\":\"http://odata.org/test/PrimitiveResultOperation2\"}]," + "\"#TestModel.ComplexResultOperation\":{\"title\":\"ComplexResultOperation\",\"target\":\"http://odata.org/test/ComplexResultOperation\"}", ExpectedServiceOperationDescriptor = new[] { new ServiceOperationDescriptor { IsAction = true, Metadata = "http://odata.org/test/$metadata#TestModel.PrimitiveResultOperation", Title = "PrimitiveResultOperation", Target = "http://odata.org/test/PrimitiveResultOperation1" }, new ServiceOperationDescriptor { IsAction = true, Metadata = "http://odata.org/test/$metadata#TestModel.PrimitiveResultOperation", Title = "TestModel.PrimitiveResultOperation", Target = "http://odata.org/test/PrimitiveResultOperation2" }, new ServiceOperationDescriptor { IsAction = true, Metadata = "http://odata.org/test/$metadata#TestModel.ComplexResultOperation", Title = "ComplexResultOperation", Target = "http://odata.org/test/ComplexResultOperation" } } }, new { DebugDescription = "function group with overloads", Json = "\"#TestModel.FunctionImportWithOverload\":{}", ExpectedServiceOperationDescriptor = new[] { new ServiceOperationDescriptor { IsAction = false, Metadata = "http://odata.org/test/$metadata#TestModel.FunctionImportWithOverload", Title = "TestModel.FunctionImportWithOverload", Target = "http://odata.org/test/Cities(1)/TestModel.FunctionImportWithOverload" }, } }, new { DebugDescription = "function group with overloads and the overload with 0 parameter", Json = "\"#TestModel.FunctionImportWithOverload\":{}," + "\"#TestModel.FunctionImportWithOverload()\":{}", ExpectedServiceOperationDescriptor = new[] { new ServiceOperationDescriptor { IsAction = false, Metadata = "http://odata.org/test/$metadata#TestModel.FunctionImportWithOverload", Title = "TestModel.FunctionImportWithOverload", Target = "http://odata.org/test/Cities(1)/TestModel.FunctionImportWithOverload" }, new ServiceOperationDescriptor { IsAction = false, Metadata = "http://odata.org/test/$metadata#TestModel.FunctionImportWithOverload" + Uri.EscapeDataString("()"), Title = "TestModel.FunctionImportWithOverload", Target = "http://odata.org/test/Cities(1)/TestModel.FunctionImportWithOverload" }, } }, new { DebugDescription = "function group with overloads and the overload with 1 parameter", Json = "\"#TestModel.FunctionImportWithOverload\":{}," + "\"#TestModel.FunctionImportWithOverload(p1)\":{}", ExpectedServiceOperationDescriptor = new[] { new ServiceOperationDescriptor { IsAction = false, Metadata = "http://odata.org/test/$metadata#TestModel.FunctionImportWithOverload", Title = "TestModel.FunctionImportWithOverload", Target = "http://odata.org/test/Cities(1)/TestModel.FunctionImportWithOverload" }, new ServiceOperationDescriptor { IsAction = false, Metadata = "http://odata.org/test/$metadata#TestModel.FunctionImportWithOverload" + Uri.EscapeDataString("(p1)"), Title = "TestModel.FunctionImportWithOverload", Target = "http://odata.org/test/Cities(1)/TestModel.FunctionImportWithOverload(p1=@p1)" }, } }, new { DebugDescription = "three overloads of an operation, with 0, 1 and 2 parameters", Json = "\"#TestModel.FunctionImportWithOverload()\":{}," + "\"#TestModel.FunctionImportWithOverload(p1)\":{}," + "\"#TestModel.FunctionImportWithOverload(p1,p2)\":{}", ExpectedServiceOperationDescriptor = new[] { new ServiceOperationDescriptor { IsAction = false, Metadata = "http://odata.org/test/$metadata#TestModel.FunctionImportWithOverload" + Uri.EscapeDataString("()"), Title = "TestModel.FunctionImportWithOverload", Target = "http://odata.org/test/Cities(1)/TestModel.FunctionImportWithOverload" }, new ServiceOperationDescriptor { IsAction = false, Metadata = "http://odata.org/test/$metadata#TestModel.FunctionImportWithOverload" + Uri.EscapeDataString("(p1)"), Title = "TestModel.FunctionImportWithOverload", Target = "http://odata.org/test/Cities(1)/TestModel.FunctionImportWithOverload(p1=@p1)" }, new ServiceOperationDescriptor { IsAction = false, Metadata = "http://odata.org/test/$metadata#TestModel.FunctionImportWithOverload" + Uri.EscapeDataString("(p1,p2)"), Title = "TestModel.FunctionImportWithOverload", Target = "http://odata.org/test/Cities(1)/TestModel.FunctionImportWithOverload(p1=@p1,p2=@p2)" }, } }, new { DebugDescription = "Two overloads of an operation, one with target and title, the other with 2 targets and 1 title", Json = "\"#TestModel.FunctionImportWithOverload()\":[{\"title\":\"FunctionImportWithOverload\",\"target\":\"http://odata.org/test/FunctionImportWithOverload/Target1\"},{\"target\":\"http://odata.org/test/FunctionImportWithOverload/Target2\"}]," + "\"#TestModel.FunctionImportWithOverload(p1)\":{\"title\":\"FunctionImportWithOverload(p1)\",\"target\":\"http://odata.org/test/FunctionImportWithOverload(p1=@p1)\"}", ExpectedServiceOperationDescriptor = new[] { new ServiceOperationDescriptor { IsAction = false, Metadata = "http://odata.org/test/$metadata#TestModel.FunctionImportWithOverload" + Uri.EscapeDataString("()"), Title = "FunctionImportWithOverload", Target = "http://odata.org/test/FunctionImportWithOverload/Target1" }, new ServiceOperationDescriptor { IsAction = false, Metadata = "http://odata.org/test/$metadata#TestModel.FunctionImportWithOverload" + Uri.EscapeDataString("()"), Title = "TestModel.FunctionImportWithOverload", Target = "http://odata.org/test/FunctionImportWithOverload/Target2" }, new ServiceOperationDescriptor { IsAction = false, Metadata = "http://odata.org/test/$metadata#TestModel.FunctionImportWithOverload" + Uri.EscapeDataString("(p1)"), Title = "FunctionImportWithOverload(p1)", Target = "http://odata.org/test/FunctionImportWithOverload(p1=@p1)" } } }, new { DebugDescription = "The operation that is not in model", Json = "\"#TestModel.UnknownOperation()\":[{\"title\":\"FunctionImportWithOverload\",\"target\":\"http://odata.org/test/FunctionImportWithOverload/Target1\"}]", ExpectedServiceOperationDescriptor = new ServiceOperationDescriptor[] {}, }, new { DebugDescription = "Single operation with title and a operation that is not in model", Json = "\"#TestModel.PrimitiveResultOperation\":{\"title\":\"PrimitiveResultOperation\"}," + "\"#TestModel.UnknownOperation\":{\"title\":\"UnknownOperation\"}", ExpectedServiceOperationDescriptor = new[] { new ServiceOperationDescriptor { IsAction = true, Metadata = "http://odata.org/test/$metadata#TestModel.PrimitiveResultOperation", Title = "PrimitiveResultOperation", Target = "http://odata.org/test/Cities(1)/TestModel.PrimitiveResultOperation" } } }, }; IEnumerable <PayloadReaderTestDescriptor> testDescriptors = testCases.Select( t => new PayloadReaderTestDescriptor(this.Settings) { DebugDescription = t.DebugDescription, PayloadEdmModel = model, PayloadElement = PayloadBuilder.Entity("TestModel.CityType") .JsonRepresentation( "{" + "\"" + JsonLightConstants.ODataPropertyAnnotationSeparator + JsonLightConstants.ODataContextAnnotationName + "\":\"http://odata.org/test/$metadata#DefaultContainer.Cities/$entity\"," + "\"" + JsonLightConstants.ODataPropertyAnnotationSeparator + JsonLightConstants.ODataTypeAnnotationName + "\":\"TestModel.CityType\"," + "\"Id\":1," + "\"Name\":\"cityTypeName\"," + t.Json + "}") .ExpectedEntityType(cityType, cities), ExpectedResultPayloadElement = (tc) => { var entityInstance = PayloadBuilder.Entity("TestModel.CityType"). PrimitiveProperty("Id", 1). PrimitiveProperty("Name", "cityTypeName"). StreamProperty("Skyline", "http://odata.org/test/Cities(1)/Skyline", "http://odata.org/test/Cities(1)/Skyline"). NavigationProperty("CityHall", "http://odata.org/test/Cities(1)/CityHall"). NavigationProperty("DOL", "http://odata.org/test/Cities(1)/DOL"). NavigationProperty("PoliceStation", "http://odata.org/test/Cities(1)/PoliceStation"); foreach (var op in t.ExpectedServiceOperationDescriptor) { entityInstance.OperationDescriptor(op); } return(entityInstance); }, SkipTestConfiguration = tc => tc.IsRequest }); this.CombinatorialEngineProvider.RunCombinations( testDescriptors, this.ReaderTestConfigurationProvider.JsonLightFormatConfigurations, (testDescriptor, testConfiguration) => { if (testConfiguration.IsRequest) { testDescriptor = new PayloadReaderTestDescriptor(testDescriptor); testDescriptor.ExpectedResultNormalizers.Add(tc => RemoveOperationsNormalizer.Normalize); } // These descriptors are already tailored specifically for Json Light and // do not require normalization. testDescriptor.TestDescriptorNormalizers.Clear(); testDescriptor.RunTest(testConfiguration); }); }
public void InvalidEntityReferenceLinksReaderAtomTest() { IEnumerable <PayloadReaderTestDescriptor> testDescriptors = new PayloadReaderTestDescriptor[] { #region Wrong name and namespace // Wrong name new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.LinkCollection().XmlRepresentation("<m:Ref></m:Ref>"), ExpectedException = ODataExpectedExceptions.ODataException("ODataAtomEntityReferenceLinkDeserializer_InvalidEntityReferenceLinksStartElement", "Ref", TestAtomConstants.ODataMetadataNamespace) }, // Wrong namespace new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.LinkCollection().XmlRepresentation("<m:ref></m:ref>"), ExpectedException = ODataExpectedExceptions.ODataException("ODataAtomEntityReferenceLinkDeserializer_InvalidEntityReferenceLinksStartElement", "ref", TestAtomConstants.ODataMetadataNamespace) }, #endregion #region Duplicate error elements // duplicate 'm:count' element new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.LinkCollection().InlineCount(1).XmlRepresentation("<feed><m:count>1</m:count><m:count>2</m:count><m:ref id=\"http://odata.org/refid\"></m:ref></feed>"), ExpectedResultCallback = tc => new PayloadReaderTestExpectedResult(this.Settings.ExpectedResultSettings) { ExpectedPayloadElement = PayloadBuilder.LinkCollection(), ExpectedException = ODataExpectedExceptions.ODataException("ODataAtomEntityReferenceLinkDeserializer_MultipleEntityReferenceLinksElementsWithSameName", TestAtomConstants.ODataMetadataNamespace, TestAtomConstants.ODataCountElementName) } }, // duplicate 'd:next' element new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.LinkCollection().NextLink("http://odata.org/next1").XmlRepresentation("<feed><d:next>http://odata.org/next1</d:next><d:next>http://odata.org/next2</d:next></feed>"), ExpectedResultCallback = tc => new PayloadReaderTestExpectedResult(this.Settings.ExpectedResultSettings) { ExpectedPayloadElement = PayloadBuilder.LinkCollection(), ExpectedException = ODataExpectedExceptions.ODataException("ODataAtomEntityReferenceLinkDeserializer_MultipleEntityReferenceLinksElementsWithSameName", TestAtomConstants.ODataNamespace, TestAtomConstants.ODataNextLinkElementName) } }, #endregion Duplicate error elements #region Element content in string elements new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.LinkCollection().InlineCount(1).XmlRepresentation("<feed><m:count><foo></foo>1<bar /></m:count></feed>"), ExpectedResultCallback = tc => new PayloadReaderTestExpectedResult(this.Settings.ExpectedResultSettings) { ExpectedPayloadElement = PayloadBuilder.LinkCollection(), ExpectedException = ODataExpectedExceptions.ODataException("XmlReaderExtension_InvalidNodeInStringValue", "Element"), } }, new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.LinkCollection().NextLink("http://odata.org/next1").XmlRepresentation("<feed><d:next><foo></foo>http://odata.org/next1<bar /></d:next></feed>"), ExpectedResultCallback = tc => new PayloadReaderTestExpectedResult(this.Settings.ExpectedResultSettings) { ExpectedPayloadElement = PayloadBuilder.LinkCollection(), ExpectedException = ODataExpectedExceptions.ODataException("XmlReaderExtension_InvalidNodeInStringValue", "Element"), } }, #endregion Element content in string elements }; this.CombinatorialEngineProvider.RunCombinations( testDescriptors, this.ReaderTestConfigurationProvider.AtomFormatConfigurations, (testDescriptor, testConfiguration) => { testDescriptor.RunTest(testConfiguration); }); }
public void ReadODataOperationErrorTest() { IEdmModel model = Test.OData.Utils.Metadata.TestModels.BuildTestModel(); IEdmEntityContainer container = model.FindEntityContainer("DefaultContainer"); IEdmEntitySet cities = container.FindEntitySet("Cities"); IEdmType cityType = model.FindType("TestModel.CityType"); var testCases = new[] { new { DebugDescription = "Metadata reference property not supported in request.", Json = "\"#operationMetadata\":{}", SkipForRequest = false, SkipForResponse = true, ExpectedException = ODataExpectedExceptions.ODataException("ODataJsonLightResourceDeserializer_MetadataReferencePropertyInRequest"), }, new { DebugDescription = "Duplicated metadata reference property names.", Json = "\"#TestModel.PrimitiveResultOperation\":{}, \"#TestModel.PrimitiveResultOperation\":{}", SkipForRequest = true, SkipForResponse = false, ExpectedException = ODataExpectedExceptions.ODataException("DuplicatePropertyNamesNotAllowed", "#TestModel.PrimitiveResultOperation"), }, new { DebugDescription = "Operation value must start with start array or start object.", Json = "\"#TestModel.PrimitiveResultOperation\":null", SkipForRequest = true, SkipForResponse = false, ExpectedException = ODataExpectedExceptions.ODataException("ODataJsonOperationsDeserializerUtils_OperationsPropertyMustHaveObjectValue", "#TestModel.PrimitiveResultOperation", "PrimitiveValue"), }, new { DebugDescription = "Operation value can only have at most 1 title.", Json = "\"#TestModel.PrimitiveResultOperation\":{\"title\":\"PrimitiveResultOperation\",\"title\":\"PrimitiveResultOperation\"}", SkipForRequest = true, SkipForResponse = false, ExpectedException = ODataExpectedExceptions.ODataException("ODataJsonLightResourceDeserializer_MultipleOptionalPropertiesInOperation", "title", "#TestModel.PrimitiveResultOperation"), }, new { DebugDescription = "Operation value can only have at most 1 target.", Json = "\"#TestModel.PrimitiveResultOperation\":{\"target\":\"http://www.example.com/foo\",\"target\":\"http://www.example.com/foo\"}", SkipForRequest = true, SkipForResponse = false, ExpectedException = ODataExpectedExceptions.ODataException("ODataJsonLightResourceDeserializer_MultipleOptionalPropertiesInOperation", "target", "#TestModel.PrimitiveResultOperation"), }, new { DebugDescription = "Operation values inside an array must have target.", Json = "\"#TestModel.PrimitiveResultOperation\":[{},{}]", SkipForRequest = true, SkipForResponse = false, ExpectedException = ODataExpectedExceptions.ODataException("ODataJsonLightResourceDeserializer_OperationMissingTargetProperty", "#TestModel.PrimitiveResultOperation"), }, }; IEnumerable <PayloadReaderTestDescriptor> testDescriptors = testCases.Select( t => new PayloadReaderTestDescriptor(this.Settings) { IgnorePropertyOrder = true, DebugDescription = t.DebugDescription, PayloadEdmModel = model, PayloadElement = PayloadBuilder.Entity("TestModel.CityType") .JsonRepresentation( "{" + "\"" + JsonLightConstants.ODataPropertyAnnotationSeparator + JsonLightConstants.ODataContextAnnotationName + "\":\"http://odata.org/test/$metadata#DefaultContainer.Cities/$entity\"," + "\"" + JsonLightConstants.ODataPropertyAnnotationSeparator + JsonLightConstants.ODataTypeAnnotationName + "\":\"TestModel.CityType\"," + "\"Id\":1," + t.Json + "}") .ExpectedEntityType(cityType, cities), ExpectedException = t.ExpectedException, SkipTestConfiguration = tc => tc.IsRequest ? t.SkipForRequest : t.SkipForResponse }); this.CombinatorialEngineProvider.RunCombinations( testDescriptors, this.ReaderTestConfigurationProvider.JsonLightFormatConfigurations, (testDescriptor, testConfiguration) => { if (testConfiguration.IsRequest) { testDescriptor = new PayloadReaderTestDescriptor(testDescriptor); testDescriptor.ExpectedResultNormalizers.Add(tc => RemoveOperationsNormalizer.Normalize); } // These descriptors are already tailored specifically for Json Light and // do not require normalization. testDescriptor.TestDescriptorNormalizers.Clear(); testDescriptor.RunTest(testConfiguration); }); }
public void CollectionWithoutExpectedTypeAndWithoutMetadataTest() { const string complexType1Name = "TestModel.TestComplexType1"; const string complexType2Name = "TestModel.TestComplexType2"; #region Test cases where the collection does not specify a type name IEnumerable <PayloadReaderTestDescriptor> noCollectionTypeNameTestDescriptors = new[] { // Primitive collection containing items of the same primitive type new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.PrimitiveMultiValue().Item(1).Item(2).Item(3) }, // Primitive collection containing string items where some don't specify the type name new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.PrimitiveMultiValue().Item("One").Item(new PrimitiveValue(/*fullTypeName*/ null, "Two")).Item("Three") }, // Primitive collection containing string items where the first doesn't specify the type name new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.PrimitiveMultiValue().Item(new PrimitiveValue(/*fullTypeName*/ null, "One")).Item("Two").Item("Three") }, // Primitive collection containing items of different primitive types new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.PrimitiveMultiValue().Item(1).Item(true).Item(2), ExpectedResultCallback = tc => new PayloadReaderTestExpectedResult(this.Settings.ExpectedResultSettings) { ExpectedException = ODataExpectedExceptions.ODataException("CollectionWithoutExpectedTypeValidator_IncompatibleItemTypeName", "Edm.Boolean", "Edm.Int32") } }, // Complex collection containing items of different complex type (correct type attribute value) new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.ComplexMultiValue() .Item(PayloadBuilder.ComplexValue(complexType1Name).PrimitiveProperty("Property1", "Foo")) .Item(PayloadBuilder.ComplexValue(complexType2Name).PrimitiveProperty("Property1", "Foo")), ExpectedException = ODataExpectedExceptions.ODataException("CollectionWithoutExpectedTypeValidator_IncompatibleItemTypeName", complexType2Name, complexType1Name), }, // Primitive collection containing items of different primitive types (including one not specifying the type name) new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.PrimitiveMultiValue().Item(new PrimitiveValue(/*fullTypeName*/ null, "One")).Item("Two").Item(3), ExpectedResultCallback = tc => new PayloadReaderTestExpectedResult(this.Settings.ExpectedResultSettings) { ExpectedException = ODataExpectedExceptions.ODataException("CollectionWithoutExpectedTypeValidator_IncompatibleItemTypeName", "Edm.Int32", "Edm.String") } }, // Complex collection containing complex items without type names new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.ComplexMultiValue() .Item(PayloadBuilder.ComplexValue().PrimitiveProperty("Property1", "Foo")) .Item(PayloadBuilder.ComplexValue().PrimitiveProperty("Property2", "Bar")), }, }; #endregion Test cases where the collection does not specify a type name #region Test cases where the collection does specify a type name IEnumerable <PayloadReaderTestDescriptor> collectionTypeNameTestDescriptors = new[] { // Primitive collection containing items of the same primitive type and the items have type names as well new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.PrimitiveMultiValue(EntityModelUtils.GetCollectionTypeName("Edm.Int32")).Item(1).Item(2).Item(3) }, // Primitive collection containing string items where some don't specify the type name new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.PrimitiveMultiValue(EntityModelUtils.GetCollectionTypeName("Edm.String")).Item("One").Item(new PrimitiveValue(/*fullTypeName*/ null, "Two")).Item("Three") }, // Primitive collection containing string items where the first doesn't specify the type name new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.PrimitiveMultiValue(EntityModelUtils.GetCollectionTypeName("Edm.String")).Item(new PrimitiveValue(/*fullTypeName*/ null, "One")).Item("Two").Item("Three") }, // Primitive collection containing some items of a different primitive type new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.PrimitiveMultiValue(EntityModelUtils.GetCollectionTypeName("Edm.String")).Item(new PrimitiveValue(/*fullTypeName*/ null, "One")).Item("Two").Item(3), ExpectedResultCallback = tc => new PayloadReaderTestExpectedResult(this.Settings.ExpectedResultSettings) { ExpectedException = ODataExpectedExceptions.ODataException("CollectionWithoutExpectedTypeValidator_IncompatibleItemTypeName", "Edm.Int32", "Edm.String") } }, // Primitive collection containing items of the same primitive type where some specify type names new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.PrimitiveMultiValue(EntityModelUtils.GetCollectionTypeName("Edm.Int32")).Item(1).Item(new PrimitiveValue(/*fullTypeName*/ null, 2)).Item(3), }, // Primitive collection containing items of different primitive types new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.PrimitiveMultiValue(EntityModelUtils.GetCollectionTypeName("Edm.String")).Item(1).Item(true).Item(2), ExpectedResultCallback = tc => new PayloadReaderTestExpectedResult(this.Settings.ExpectedResultSettings) { ExpectedException = ODataExpectedExceptions.ODataException("CollectionWithoutExpectedTypeValidator_IncompatibleItemTypeName", "Edm.Int32", "Edm.String") } }, // Complex collection containing items of different complex type new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.ComplexMultiValue(EntityModelUtils.GetCollectionTypeName(complexType1Name)) .Item(PayloadBuilder.ComplexValue(complexType2Name).PrimitiveProperty("Property1", "Foo")), ExpectedException = ODataExpectedExceptions.ODataException("CollectionWithoutExpectedTypeValidator_IncompatibleItemTypeName", complexType2Name, complexType1Name), }, // Complex collection containing items of different complex type new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.ComplexMultiValue(EntityModelUtils.GetCollectionTypeName(complexType1Name)) .Item(PayloadBuilder.ComplexValue(complexType1Name).PrimitiveProperty("Property1", "Foo")) .Item(PayloadBuilder.ComplexValue(complexType2Name).PrimitiveProperty("Property1", "Foo")), ExpectedException = ODataExpectedExceptions.ODataException("CollectionWithoutExpectedTypeValidator_IncompatibleItemTypeName", complexType2Name, complexType1Name), }, }; #endregion noCollectionTypeNameTestDescriptors = noCollectionTypeNameTestDescriptors.Select(td => td.InProperty()); collectionTypeNameTestDescriptors = collectionTypeNameTestDescriptors.Select(td => td.InProperty()); this.CombinatorialEngineProvider.RunCombinations( noCollectionTypeNameTestDescriptors.Concat(collectionTypeNameTestDescriptors), this.ReaderTestConfigurationProvider.JsonLightFormatConfigurations, (testDescriptor, testConfiguration) => { testDescriptor.RunTest(testConfiguration); }); }
public void JsonLightTaupoSerializerCollectionTest() { var testCases = new JsonLightSerializerTestCase[] { // Primitive collection new JsonLightSerializerTestCase { PayloadElement = new PrimitiveCollection(PayloadBuilder.PrimitiveValue((long)1), PayloadBuilder.PrimitiveValue((long)2)).WithContextUri("http://odata.org/metadatauri"), ExpectedJson = @" { """ + JsonLightConstants.ODataPropertyAnnotationSeparator + JsonLightConstants.ODataContextAnnotationName + @""":""http://odata.org/metadatauri"", """ + JsonLightConstants.ODataValuePropertyName + @""":[1,2] }" }, // Complex collection new JsonLightSerializerTestCase { PayloadElement = new ComplexInstanceCollection( PayloadBuilder.ComplexValue("TestModel.City") .PrimitiveProperty("City", "Vienna")) .WithContextUri("http://odata.org/metadatauri"), ExpectedJson = @" { """ + JsonLightConstants.ODataPropertyAnnotationSeparator + JsonLightConstants.ODataContextAnnotationName + @""":""http://odata.org/metadatauri"", """ + JsonLightConstants.ODataValuePropertyName + @""":[{ """ + JsonLightConstants.ODataPropertyAnnotationSeparator + JsonLightConstants.ODataTypeAnnotationName + @""":""TestModel.City"", ""City"":""Vienna"" }] }" }, }; this.CombinatorialEngineProvider.RunCombinations( testCases, (testCase) => { JsonValue actualValue = this.JsonLightSerializer.ConvertToJsonLightValue(testCase.PayloadElement); JsonValue expectedValue = JsonTextPreservingParser.ParseValue(new StringReader(testCase.ExpectedJson)); this.JsonValueComparer.Compare(expectedValue, actualValue); }); }
public IEnumerable <PayloadReaderTestDescriptor> CreateInvalidCollectionsWithTypeNames(bool expectedTypeWillBeUsed) { EdmModel model = new EdmModel(); EdmComplexType itemComplexType = model.ComplexType("ItemComplexType"); model.ComplexType("ExtraComplexType"); model = model.Fixup(); // Add invalid cases var testDescriptors = new[] { // Invalid collection type name new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.PrimitiveMultiValue("") .WithTypeAnnotation(EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetInt32(false))), PayloadEdmModel = model, ExpectedException = ODataExpectedExceptions.ODataException("ValidationUtils_UnrecognizedTypeName", string.Empty), }, new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.PrimitiveMultiValue(EntityModelUtils.GetCollectionTypeName("")) .WithTypeAnnotation(EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetInt32(false))), PayloadEdmModel = model, ExpectedException = ODataExpectedExceptions.ODataException("ValidationUtils_UnrecognizedTypeName", EntityModelUtils.GetCollectionTypeName("")), }, // Invalid collection type name new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.PrimitiveMultiValue("collection(Edm.Int32)") .WithTypeAnnotation(EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetInt32(false))), PayloadEdmModel = model, ExpectedException = ODataExpectedExceptions.ODataException("ValidationUtils_UnrecognizedTypeName", "collection(Edm.Int32)"), }, new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.PrimitiveMultiValue("foo") .WithTypeAnnotation(EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetInt32(false))), PayloadEdmModel = model, ExpectedException = ODataExpectedExceptions.ODataException("ValidationUtils_UnrecognizedTypeName", "foo"), }, // Non existant type name new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.PrimitiveMultiValue(EntityModelUtils.GetCollectionTypeName("TestModel.NonExistant")) .WithTypeAnnotation(EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetInt32(false))), PayloadEdmModel = model, ExpectedException = ODataExpectedExceptions.ODataException("ValidationUtils_UnrecognizedTypeName", EntityModelUtils.GetCollectionTypeName("TestModel.NonExistant")), }, // Type of the item differs from the type of the collection new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.PrimitiveMultiValue(EntityModelUtils.GetCollectionTypeName("Edm.String")) .Item(-42) .WithTypeAnnotation(EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetString(true))), PayloadEdmModel = model, ExpectedResultCallback = tc => new PayloadReaderTestExpectedResult(this.Settings.ExpectedResultSettings) { ExpectedException = ODataExpectedExceptions.ODataException("ReaderValidationUtils_CannotConvertPrimitiveValue", "-42", "Edm.String") }, }, new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.ComplexMultiValue(EntityModelUtils.GetCollectionTypeName("TestModel.ItemComplexType")) .Item(PayloadBuilder.ComplexValue("TestModel.ExtraComplexType")) .WithTypeAnnotation(EdmCoreModel.GetCollection(itemComplexType.ToTypeReference())), PayloadEdmModel = model, ExpectedException = ODataExpectedExceptions.ODataException("ValidationUtils_IncompatibleType", "TestModel.ExtraComplexType", "TestModel.ItemComplexType"), } }; if (expectedTypeWillBeUsed) { testDescriptors = testDescriptors.Concat(new[] { // Type differs from the declared/expected type new PayloadReaderTestDescriptor(this.Settings) { PayloadElement = PayloadBuilder.PrimitiveMultiValue(EntityModelUtils.GetCollectionTypeName("Edm.String")) .WithTypeAnnotation(EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetInt32(false))), PayloadEdmModel = model, ExpectedException = ODataExpectedExceptions.ODataException("ValidationUtils_IncompatibleType", EntityModelUtils.GetCollectionTypeName("Edm.String"), EntityModelUtils.GetCollectionTypeName("Edm.Int32")), }, }).ToArray(); } foreach (var testDescriptor in testDescriptors) { testDescriptor.PayloadNormalizers.Add((tc) => tc.Format == ODataFormat.Json ? AddJsonLightTypeAnnotationToCollectionsVisitor.Normalize : (Func <ODataPayloadElement, ODataPayloadElement>)null); } return(testDescriptors); }
public void StreamWriteReadEntry() { EdmModel model = Microsoft.Test.OData.Utils.Metadata.TestModels.BuildTestModel(); ComplexInstance complexValue = ODataStreamingTestCase.GetComplexInstanceWithManyPrimitiveProperties(model); var payloadDescriptors = new PayloadTestDescriptor[] { // Multiple nesting of Complex Values and Multiple Values. new PayloadTestDescriptor() { PayloadElement = PayloadBuilder.Property("propertyName", complexValue), PayloadEdmModel = model.Clone(), SkipTestConfiguration = (tc) => tc.Version < ODataVersion.V4 }.InComplexValue().InCollection().InProperty().InComplexValue().InCollection().InProperty().InComplexValue() .InCollection().InProperty().InComplexValue().InCollection().InProperty().InEntity(), // Multiple nesting of Complex Values. new PayloadTestDescriptor() { PayloadElement = PayloadBuilder.Property("propertyName", complexValue), PayloadEdmModel = model.Clone(), }.InComplexValue().InProperty().InComplexValue().InProperty().InComplexValue().InProperty() .InComplexValue().InProperty().InComplexValue().InProperty().InComplexValue().InProperty().InEntity(1, 0), // Entry With an Expanded Link which is an entry containing a Complex collection. new PayloadTestDescriptor() { PayloadElement = complexValue, PayloadEdmModel = model.Clone(), SkipTestConfiguration = (tc) => tc.Version < ODataVersion.V4 }.InCollection(1, 1).InProperty().InComplexValue().InCollection().InProperty().InEntity().InEntryWithExpandedLink(/*singletonRelationship*/ true), // Entry With an Expanded Link which is a Feed containing an Entry with Complex collection properties. new PayloadTestDescriptor() { PayloadElement = complexValue, PayloadEdmModel = model.Clone(), SkipTestConfiguration = (tc) => tc.Version < ODataVersion.V4 }.InCollection(1, 2).InProperty().InComplexValue(1, 1).InCollection(1, 0).InProperty().InEntity(1, 1).InFeed(2).InEntryWithExpandedLink(), // Entry With Nested Expanded Links which contain Entries. new PayloadTestDescriptor() { PayloadElement = PayloadBuilder.Property("propertyName", complexValue), PayloadEdmModel = model.Clone(), }.InEntity(1, 1, ODataVersion.V4).InEntryWithExpandedLink(/*singletonRelationship*/ true).InEntryWithExpandedLink(/*singletonRelationship*/ true) .InEntryWithExpandedLink(/*singletonRelationship*/ true).InEntryWithExpandedLink(/*singletonRelationship*/ true) .InEntryWithExpandedLink(/*singletonRelationship*/ true).InEntryWithExpandedLink(/*singletonRelationship*/ true), // Entry with inline expanded feed association to an arbitrary depth (7) where the expanded feed has no entries new PayloadTestDescriptor() { PayloadElement = PayloadBuilder.EntitySet().WithTypeAnnotation(model.FindDeclaredType("TestModel.OfficeType")), PayloadEdmModel = model.Clone(), }.InEntryWithExpandedLink().InFeed(2).InEntryWithExpandedLink().InFeed(2).InEntryWithExpandedLink().InFeed(2).InEntryWithExpandedLink() .InFeed(2).InEntryWithExpandedLink(), }; var testDescriptors = this.PayloadDescriptorsToStreamDescriptors(payloadDescriptors); //ToDo: Fix places where we've lost JsonVerbose coverage to add JsonLight this.CombinatorialEngineProvider.RunCombinations( testDescriptors, this.WriterTestConfigurationProvider.ExplicitFormatConfigurationsWithIndent.Where(tc => tc.Synchronous && tc.Format == ODataFormat.Atom), (testDescriptor, testConfiguration) => { testDescriptor.RunTest(testConfiguration); }); }
public void HomogeneousCollectionReaderAtomTest() { EdmModel edmModel = new EdmModel(); EdmComplexType edmComplexTypeEmpty = new EdmComplexType(ModelNamespace, "EmptyComplexType"); edmModel.AddElement(edmComplexTypeEmpty); EdmComplexType edmComplexTypeCity = new EdmComplexType(ModelNamespace, "CityType"); edmComplexTypeCity.AddStructuralProperty("Name", EdmCoreModel.Instance.GetString(true)); edmModel.AddElement(edmComplexTypeCity); EdmComplexType edmComplexTypeAddress = new EdmComplexType(ModelNamespace, "AddressType"); edmComplexTypeAddress.AddStructuralProperty("Street", EdmCoreModel.Instance.GetString(true)); edmModel.AddElement(edmComplexTypeAddress); edmModel.Fixup(); IEnumerable <PayloadReaderTestDescriptor> testDescriptors = new PayloadReaderTestDescriptor[] { // complex collection with primitive expected type new PayloadReaderTestDescriptor(this.PayloadTestDescriptorSettings) { PayloadElement = new ComplexInstanceCollection( PayloadBuilder.ComplexValue("TestModel.CityType").Property("Name", PayloadBuilder.PrimitiveValue("Vienna")), PayloadBuilder.ComplexValue("TestModel.CityType").Property("Name", PayloadBuilder.PrimitiveValue("Prague")) ).ExpectedCollectionItemType(EdmDataTypes.Int32).CollectionName(null), PayloadEdmModel = edmModel, ExpectedException = ODataExpectedExceptions.ODataException("ValidationUtils_IncorrectTypeKind", "TestModel.CityType", "Primitive", "Complex"), }, // primitive collection in XMLRepresentation with complex expected type. new PayloadReaderTestDescriptor(this.PayloadTestDescriptorSettings) { PayloadElement = new ComplexInstanceCollection( PayloadBuilder.ComplexValue("TestModel.CityType"), PayloadBuilder.ComplexValue("TestModel.CityType") ).ExpectedCollectionItemType(edmComplexTypeCity).CollectionName(null) .XmlRepresentation(@" <m:value> <m:element m:type='Edm.Int32'>1</m:element> <m:element m:type='Edm.Int32'>2</m:element> </m:value>"), PayloadEdmModel = edmModel, ExpectedException = ODataExpectedExceptions.ODataException("ValidationUtils_IncorrectTypeKind", "Edm.Int32", "Complex", "Primitive"), }, }; this.CombinatorialEngineProvider.RunCombinations( testDescriptors, this.ReaderTestConfigurationProvider.AtomFormatConfigurations, (testDescriptor, testConfiguration) => { testDescriptor.RunTest(testConfiguration); }); }