public void StreamPropertiesProjectionTest() { EdmModel model = new EdmModel(); var container = new EdmEntityContainer("TestModel", "DefaultContainer"); model.AddElement(container); EdmEntityType townType = model.EntityType("TownType"); townType.KeyProperty("Id", EdmCoreModel.Instance.GetInt32(false)); townType.StreamProperty("MapSmall"); townType.StreamProperty("MapMedium"); townType.NavigationProperty("NavProp", townType); EdmEntityType cityType = model.EntityType("CityType", null, townType); cityType.StreamProperty("CityLogo"); EdmEntitySet townsSet = model.EntitySet("Towns", townType); model.Fixup(); var testCases = new ProjectionTestCase[] { #region No $select new ProjectionTestCase { DebugDescription = "No $select => three templatized properties.", PayloadEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1), ExpectedEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).StreamProperty("MapSmall").StreamProperty("MapMedium").StreamProperty("CityLogo").NavigationProperty("NavProp", /*url*/null), ProjectionString = null, }, new ProjectionTestCase { DebugDescription = "No $select + one property in the payload => two templatized properties.", PayloadEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).StreamProperty("MapSmall", "http://odata.org/stream/read"), ExpectedEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).StreamProperty("MapSmall", "http://odata.org/stream/read").StreamProperty("MapMedium").StreamProperty("CityLogo").NavigationProperty("NavProp", /*url*/null), ProjectionString = null, }, new ProjectionTestCase { DebugDescription = "No $select + three properties in the payload => no templatized properties.", PayloadEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).StreamProperty("MapSmall", "http://odata.org/stream/read").StreamProperty("MapMedium", "http://odata.org/stream/read").StreamProperty("CityLogo", "http://odata.org/stream/read"), ExpectedEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).StreamProperty("MapSmall", "http://odata.org/stream/read").StreamProperty("MapMedium", "http://odata.org/stream/read").StreamProperty("CityLogo", "http://odata.org/stream/read").NavigationProperty("NavProp", /*url*/null), ProjectionString = null, }, #endregion No $select #region Empty $select new ProjectionTestCase { DebugDescription = "Empty $select => no templatized properties.", PayloadEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1), ExpectedEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1), ProjectionString = string.Empty, }, new ProjectionTestCase { DebugDescription = "Empty $select + one property in the payload => no templatized properties.", PayloadEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).StreamProperty("MapSmall", "http://odata.org/stream/read"), ExpectedEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).StreamProperty("MapSmall", "http://odata.org/stream/read"), ProjectionString = string.Empty, }, new ProjectionTestCase { DebugDescription = "Empty $select + three properties in the payload => no templatized properties.", PayloadEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).StreamProperty("MapSmall", "http://odata.org/stream/read").StreamProperty("MapMedium", "http://odata.org/stream/read").StreamProperty("CityLogo", "http://odata.org/stream/read"), ExpectedEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).StreamProperty("MapSmall", "http://odata.org/stream/read").StreamProperty("MapMedium", "http://odata.org/stream/read").StreamProperty("CityLogo", "http://odata.org/stream/read"), ProjectionString = string.Empty, }, #endregion Empty $select #region $select=* new ProjectionTestCase { DebugDescription = "$select=* => three templatized stream properties and and one templatized navigation.", PayloadEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1), ExpectedEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).StreamProperty("MapSmall").StreamProperty("MapMedium").StreamProperty("CityLogo").NavigationProperty("NavProp", /*url*/null), ProjectionString = "*", }, new ProjectionTestCase { DebugDescription = "$select=* + one property in the payload => two templatized stream properties and one templatized navigation.", PayloadEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).StreamProperty("MapSmall", "http://odata.org/stream/read"), ExpectedEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).StreamProperty("MapSmall", "http://odata.org/stream/read").StreamProperty("MapMedium").StreamProperty("CityLogo").NavigationProperty("NavProp", /*url*/null), ProjectionString = "*", }, new ProjectionTestCase { DebugDescription = "$select=* + three properties in the payload => no templatized stream properties, one templatized navigation.", PayloadEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).StreamProperty("MapSmall", "http://odata.org/stream/read").StreamProperty("MapMedium", "http://odata.org/stream/read").StreamProperty("CityLogo", "http://odata.org/stream/read"), ExpectedEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).StreamProperty("MapSmall", "http://odata.org/stream/read").StreamProperty("MapMedium", "http://odata.org/stream/read").StreamProperty("CityLogo", "http://odata.org/stream/read").NavigationProperty("NavProp", /*url*/null), ProjectionString = "*", }, #endregion $select=* #region $select=MapMedium new ProjectionTestCase { DebugDescription = "$select=MapMedium => one templatized properties.", PayloadEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1), ExpectedEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).StreamProperty("MapMedium"), ProjectionString = "MapMedium", }, new ProjectionTestCase { DebugDescription = "$select=MapMedium + MapMedium property in the payload => no templatized properties.", PayloadEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).StreamProperty("MapMedium", "http://odata.org/stream/read"), ExpectedEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).StreamProperty("MapMedium", "http://odata.org/stream/read"), ProjectionString = "MapMedium", }, new ProjectionTestCase { DebugDescription = "$select=MapMedium + MapSmall property in the payload => one templatized properties.", PayloadEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).StreamProperty("MapSmall", "http://odata.org/stream/read"), ExpectedEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).StreamProperty("MapSmall", "http://odata.org/stream/read").StreamProperty("MapMedium"), ProjectionString = "MapMedium", }, new ProjectionTestCase { DebugDescription = "$select=MapMedium + three properties in the payload => no templatized properties.", PayloadEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).StreamProperty("MapSmall", "http://odata.org/stream/read").StreamProperty("MapMedium", "http://odata.org/stream/read").StreamProperty("CityLogo", "http://odata.org/stream/read"), ExpectedEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).StreamProperty("MapSmall", "http://odata.org/stream/read").StreamProperty("MapMedium", "http://odata.org/stream/read").StreamProperty("CityLogo", "http://odata.org/stream/read"), ProjectionString = "MapMedium", }, #endregion $select=MapMedium #region $select=NavProp/* new ProjectionTestCase { DebugDescription = "$select=NavProp/* => three templatized stream properties and and one templatized navigation.", PayloadEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).ExpandedNavigationProperty("NavProp", PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 2)), ExpectedEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).ExpandedNavigationProperty("NavProp", PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 2).StreamProperty("MapSmall").StreamProperty("MapMedium").StreamProperty("CityLogo").NavigationProperty("NavProp", /*url*/null)), ProjectionString = "NavProp/*", }, new ProjectionTestCase { DebugDescription = "$select=NavProp/* + one property in the payload => two templatized stream properties and one templatized navigation.", PayloadEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).ExpandedNavigationProperty("NavProp", PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 2).StreamProperty("MapSmall", "http://odata.org/stream/read")), ExpectedEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).ExpandedNavigationProperty("NavProp", PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 2).StreamProperty("MapSmall", "http://odata.org/stream/read").StreamProperty("MapMedium").StreamProperty("CityLogo").NavigationProperty("NavProp", /*url*/null)), ProjectionString = "NavProp/*", }, new ProjectionTestCase { DebugDescription = "$select=NavProp/* + three properties in the payload => no templatized stream properties, one templatized navigation.", PayloadEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).ExpandedNavigationProperty("NavProp", PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 2).StreamProperty("MapSmall", "http://odata.org/stream/read").StreamProperty("MapMedium", "http://odata.org/stream/read").StreamProperty("CityLogo", "http://odata.org/stream/read")), ExpectedEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).ExpandedNavigationProperty("NavProp", PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 2).StreamProperty("MapSmall", "http://odata.org/stream/read").StreamProperty("MapMedium", "http://odata.org/stream/read").StreamProperty("CityLogo", "http://odata.org/stream/read").NavigationProperty("NavProp", /*url*/null)), ProjectionString = "NavProp/*", }, #endregion $select=NavProp/* #region $select=NavProp/NavProp/MapMedium new ProjectionTestCase { DebugDescription = "$select=NavProp/NavProp/MapMedium => one templatized properties.", PayloadEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).ExpandedNavigationProperty("NavProp", PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 2).ExpandedNavigationProperty("NavProp", PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 3))), ExpectedEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).ExpandedNavigationProperty("NavProp", PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 2).ExpandedNavigationProperty("NavProp", PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 3).StreamProperty("MapMedium"))), ProjectionString = "NavProp/NavProp/MapMedium", }, #endregion $select=NavProp/NavProp/MapMedium #region $select=NavProp/NavProp new ProjectionTestCase { DebugDescription = "$select=NavProp/NavProp => three templatized stream properties and one navigation property.", PayloadEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).ExpandedNavigationProperty("NavProp", PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 2).ExpandedNavigationProperty("NavProp", PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 3))), ExpectedEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).ExpandedNavigationProperty("NavProp", PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 2).ExpandedNavigationProperty("NavProp", PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 3).StreamProperty("MapSmall").StreamProperty("MapMedium").StreamProperty("CityLogo").NavigationProperty("NavProp", /*url*/null))), ProjectionString = "NavProp/NavProp", }, #endregion $select=NavProp/NavProp #region $select=TestModel.CityType/CityLogo new ProjectionTestCase { DebugDescription = "$select=TestModel.CityType/CityLogo on base type => no templatized properties.", PayloadEntity = PayloadBuilder.Entity("TestModel.TownType").PrimitiveProperty("Id", 1), ExpectedEntity = PayloadBuilder.Entity("TestModel.TownType").PrimitiveProperty("Id", 1), ProjectionString = "TestModel.CityType/CityLogo", }, new ProjectionTestCase { DebugDescription = "$select=TestModel.CityType/CityLogo on derived type => specific property templatized.", PayloadEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1), ExpectedEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).StreamProperty("CityLogo"), ProjectionString = "TestModel.CityType/CityLogo", }, #endregion $select=TestModel.CityType/CityLogo #region $select=TestModel.CityType/MapSmall new ProjectionTestCase { DebugDescription = "$select=TestModel.CityType/MapSmall on base type => no templatized properties.", PayloadEntity = PayloadBuilder.Entity("TestModel.TownType").PrimitiveProperty("Id", 1), ExpectedEntity = PayloadBuilder.Entity("TestModel.TownType").PrimitiveProperty("Id", 1), ProjectionString = "TestModel.CityType/MapSmall", }, new ProjectionTestCase { DebugDescription = "$select=TestModel.CityType/MapSmall on derived type => specific property templatized.", PayloadEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1), ExpectedEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).StreamProperty("MapSmall"), ProjectionString = "TestModel.CityType/MapSmall", }, #endregion $select=TestModel.CityType/MapSmall #region $select=TestModel.TownType/MapSmall new ProjectionTestCase { DebugDescription = "$select=TestModel.TownType/MapSmall on base type => specific property templatized..", PayloadEntity = PayloadBuilder.Entity("TestModel.TownType").PrimitiveProperty("Id", 1), ExpectedEntity = PayloadBuilder.Entity("TestModel.TownType").PrimitiveProperty("Id", 1).StreamProperty("MapSmall"), ProjectionString = "TestModel.TownType/MapSmall", }, new ProjectionTestCase { DebugDescription = "$select=TestModel.TownType/MapSmall on derived type => specific property templatized.", PayloadEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1), ExpectedEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).StreamProperty("MapSmall"), ProjectionString = "TestModel.TownType/MapSmall", }, #endregion $select=TestModel.TownType/MapSmall }; IEnumerable<PayloadReaderTestDescriptor> testDescriptors = testCases.Select(testCase => new PayloadReaderTestDescriptor(this.Settings) { DebugDescription = testCase.DebugDescription, PayloadEdmModel = model, PayloadElement = testCase.PayloadEntity .WithContextUriProjection(testCase.ProjectionString) .ExpectedEntityType(townType, townsSet), ExpectedResultPayloadElement = tc => testCase.ExpectedEntity, ExpectedException = testCase.ExpectedException, }); this.CombinatorialEngineProvider.RunCombinations( testDescriptors, this.ReaderTestConfigurationProvider.JsonLightFormatConfigurations.Where(tc => !tc.IsRequest), (testDescriptor, testConfiguration) => { // These descriptors are already tailored specifically for Json Light and // do not require normalization. testDescriptor.TestDescriptorNormalizers.Clear(); testDescriptor.RunTest(testConfiguration); }); }
public void NavigationPropertiesProjectionTest() { EdmModel model = new EdmModel(); EdmEntityType townType = model.EntityType("TownType"); townType.KeyProperty("Id", EdmCoreModel.Instance.GetInt32(false) as EdmTypeReference); townType.NavigationProperty("NavProp1", townType); EdmEntitySet townsSet = model.EntitySet("Towns", townType); EdmEntityType cityType = new EdmEntityType("TestModel", "CityType", townType); model.AddElement(cityType); cityType.NavigationProperty("NavProp2", townType); model.EntitySet("Cities", cityType); EdmEntityType cityType2 = new EdmEntityType("TestModel", "DuplicateCityType", townType); model.AddElement(cityType2); cityType2.NavigationProperty("NavProp2", townType); model.EntitySet("DuplicateCities", cityType2); model.Fixup(); var testCases = new ProjectionTestCase[] { #region No $select new ProjectionTestCase { DebugDescription = "No $select => two templatized properties.", PayloadEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1), ExpectedEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1) .NavigationProperty("NavProp1", /*url*/null).NavigationProperty("NavProp2", /*url*/null), ProjectionString = null, }, new ProjectionTestCase { DebugDescription = "No $select + one property in the payload => one templatized properties.", PayloadEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).NavigationProperty("NavProp1", "http://odata.org/nav1"), ExpectedEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1) .NavigationProperty("NavProp1", "http://odata.org/nav1").NavigationProperty("NavProp2", /*url*/null), ProjectionString = null, }, new ProjectionTestCase { DebugDescription = "No $select + two properties in the payload => no templatized properties.", PayloadEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).NavigationProperty("NavProp1", "http://odata.org/nav1").NavigationProperty("NavProp2", "http://odata.org/nav2"), ExpectedEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1) .NavigationProperty("NavProp1", "http://odata.org/nav1").NavigationProperty("NavProp2", "http://odata.org/nav2"), ProjectionString = null, }, #endregion No $select #region Empty $select new ProjectionTestCase { DebugDescription = "Empty $select => no templatized properties.", PayloadEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1), ExpectedEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1), ProjectionString = string.Empty, }, new ProjectionTestCase { DebugDescription = "Empty $select + one property in the payload => no templatized properties.", PayloadEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).NavigationProperty("NavProp1", "http://odata.org/nav1"), ExpectedEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).NavigationProperty("NavProp1", "http://odata.org/nav1"), ProjectionString = string.Empty, }, new ProjectionTestCase { DebugDescription = "Empty $select + two properties in the payload => no templatized properties.", PayloadEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).NavigationProperty("NavProp1", "http://odata.org/nav1").NavigationProperty("NavProp2", "http://odata.org/nav2"), ExpectedEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).NavigationProperty("NavProp1", "http://odata.org/nav1").NavigationProperty("NavProp2", "http://odata.org/nav2"), ProjectionString = string.Empty, }, #endregion Empty $select #region $select=* new ProjectionTestCase { DebugDescription = "$select=* => two templatized properties.", PayloadEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1), ExpectedEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).NavigationProperty("NavProp1", /*url*/null).NavigationProperty("NavProp2", /*url*/null), ProjectionString = "*", }, new ProjectionTestCase { DebugDescription = "$select=* + one property in the payload => one templatized property.", PayloadEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).NavigationProperty("NavProp2", "http://odata.org/nav2"), ExpectedEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).NavigationProperty("NavProp2", "http://odata.org/nav2").NavigationProperty("NavProp1", /*url*/null), ProjectionString = "*", }, new ProjectionTestCase { DebugDescription = "$select=* + two properties in the payload => no templatized properties.", PayloadEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).NavigationProperty("NavProp1", "http://odata.org/nav1").NavigationProperty("NavProp2", "http://odata.org/nav2"), ExpectedEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).NavigationProperty("NavProp1", "http://odata.org/nav1").NavigationProperty("NavProp2", "http://odata.org/nav2"), ProjectionString = "*", }, #endregion $select=* #region $select=NavProp2,* new ProjectionTestCase { DebugDescription = "$select=NavProp2,* => two templatized properties.", PayloadEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1), ExpectedEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).NavigationProperty("NavProp1", /*url*/null).NavigationProperty("NavProp2", /*url*/null), ProjectionString = "NavProp2,*", }, new ProjectionTestCase { DebugDescription = "$select=NavProp2,* + NavProp2 property in the payload => one templatized property.", PayloadEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).NavigationProperty("NavProp2", "http://odata.org/nav2"), ExpectedEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).NavigationProperty("NavProp2", "http://odata.org/nav2").NavigationProperty("NavProp1", /*url*/null), ProjectionString = "NavProp2,*", }, new ProjectionTestCase { DebugDescription = "$select=NavProp2,* + NavProp1 property in the payload => one templatized property.", PayloadEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).NavigationProperty("NavProp1", "http://odata.org/nav1"), ExpectedEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).NavigationProperty("NavProp1", "http://odata.org/nav1").NavigationProperty("NavProp2", /*url*/null), ProjectionString = "NavProp2,*", }, new ProjectionTestCase { DebugDescription = "$select=NavProp2,* + two properties in the payload => no templatized properties.", PayloadEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).NavigationProperty("NavProp1", "http://odata.org/nav1").NavigationProperty("NavProp2", "http://odata.org/nav2"), ExpectedEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).NavigationProperty("NavProp1", "http://odata.org/nav1").NavigationProperty("NavProp2", "http://odata.org/nav2"), ProjectionString = "NavProp2,*", }, #endregion $select=NavProp2,* #region $select=NavProp1,NavProp2 new ProjectionTestCase { DebugDescription = "$select=NavProp1,NavProp2 => two templatized properties.", PayloadEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1), ExpectedEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).NavigationProperty("NavProp1", /*url*/null).NavigationProperty("NavProp2", /*url*/null), ProjectionString = "NavProp1,NavProp2", }, new ProjectionTestCase { DebugDescription = "$select=NavProp1,NavProp2 + NavProp2 property in the payload => one templatized properties.", PayloadEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).NavigationProperty("NavProp2", "http://odata.org/nav2"), ExpectedEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).NavigationProperty("NavProp2", "http://odata.org/nav2").NavigationProperty("NavProp1", /*url*/null), ProjectionString = "NavProp1,NavProp2", }, new ProjectionTestCase { DebugDescription = "$select=NavProp1,NavProp2 + two properties in the payload => no templatized properties.", PayloadEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).NavigationProperty("NavProp1", "http://odata.org/nav1").NavigationProperty("NavProp2", "http://odata.org/nav2"), ExpectedEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).NavigationProperty("NavProp1", "http://odata.org/nav1").NavigationProperty("NavProp2", "http://odata.org/nav2"), ProjectionString = "NavProp1,NavProp2", }, #endregion $select=NavProp1,NavProp2 #region $select=NavProp2 new ProjectionTestCase { DebugDescription = "$select=NavProp2 => one templatized property.", PayloadEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1), ExpectedEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).NavigationProperty("NavProp2", /*url*/null), ProjectionString = "NavProp2", }, new ProjectionTestCase { DebugDescription = "$select=NavProp2 + NavProp2 property in the payload => no templatized properties.", PayloadEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).NavigationProperty("NavProp2", "http://odata.org/nav2"), ExpectedEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).NavigationProperty("NavProp2", "http://odata.org/nav2"), ProjectionString = "NavProp2", }, new ProjectionTestCase { DebugDescription = "$select=NavProp2 + NavProp1 property in the payload => one templatized property.", PayloadEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).NavigationProperty("NavProp1", "http://odata.org/nav1"), ExpectedEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).NavigationProperty("NavProp1", "http://odata.org/nav1").NavigationProperty("NavProp2", /*url*/null), ProjectionString = "NavProp2", }, new ProjectionTestCase { DebugDescription = "$select=NavProp2 + two properties in the payload => no templatized properties.", PayloadEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).NavigationProperty("NavProp1", "http://odata.org/nav1").NavigationProperty("NavProp2", "http://odata.org/nav2"), ExpectedEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).NavigationProperty("NavProp1", "http://odata.org/nav1").NavigationProperty("NavProp2", "http://odata.org/nav2"), ProjectionString = "NavProp2", }, #endregion $select=NavProp2 #region $select=NavProp1/* new ProjectionTestCase { DebugDescription = "$select=NavProp1/* => three templatized stream properties and and one templatized navigation.", PayloadEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).ExpandedNavigationProperty("NavProp1", PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 2)), ExpectedEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).ExpandedNavigationProperty("NavProp1", PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 2).NavigationProperty("NavProp1", /*url*/null).NavigationProperty("NavProp2", /*url*/null)), ProjectionString = "NavProp1/*", }, #endregion $select=NavProp/* #region $select=NavProp1/NavProp1 new ProjectionTestCase { DebugDescription = "$select=NavProp1/NavProp1 => one templatized navigation property.", PayloadEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).ExpandedNavigationProperty("NavProp1", PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 2)), ExpectedEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).ExpandedNavigationProperty("NavProp1", PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 2).NavigationProperty("NavProp1", /*url*/null)), ProjectionString = "NavProp1/NavProp1", }, new ProjectionTestCase { DebugDescription = "$select=NavProp1/NavProp1 with expand => two templatized navigation properties.", PayloadEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).ExpandedNavigationProperty("NavProp1", PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 2).ExpandedNavigationProperty("NavProp1", PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 3))), ExpectedEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).ExpandedNavigationProperty("NavProp1", PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 2).ExpandedNavigationProperty("NavProp1", PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 3).NavigationProperty("NavProp1", /*url*/null).NavigationProperty("NavProp2", /*url*/null))), ProjectionString = "NavProp1/NavProp1", }, #endregion $select=NavProp1/NavProp1 #region $select=TestModel.CityType/NavProp2 new ProjectionTestCase { DebugDescription = "$select=TestModel.CityType/NavProp2 on base type => no templatized properties.", PayloadEntity = PayloadBuilder.Entity("TestModel.TownType").PrimitiveProperty("Id", 1), ExpectedEntity = PayloadBuilder.Entity("TestModel.TownType").PrimitiveProperty("Id", 1), ProjectionString = "TestModel.CityType/NavProp2", }, new ProjectionTestCase { DebugDescription = "$select=TestModel.CityType/NavProp2 on derived type => specific property templatized.", PayloadEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1), ExpectedEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).NavigationProperty("NavProp2", /*url*/null), ProjectionString = "TestModel.CityType/NavProp2", }, new ProjectionTestCase { DebugDescription = "$select=TestModel.CityType/NavProp2 on different derived type => no templatized properties.", PayloadEntity = PayloadBuilder.Entity("TestModel.DuplicateCityType").PrimitiveProperty("Id", 1), ExpectedEntity = PayloadBuilder.Entity("TestModel.DuplicateCityType").PrimitiveProperty("Id", 1), ProjectionString = "TestModel.CityType/NavProp2", }, #endregion $select=TestModel.CityType/NavProp2 #region $select=TestModel.CityType/NavProp1 new ProjectionTestCase { DebugDescription = "$select=TestModel.CityType/NavProp1 on base type => no templatized properties.", PayloadEntity = PayloadBuilder.Entity("TestModel.TownType").PrimitiveProperty("Id", 1), ExpectedEntity = PayloadBuilder.Entity("TestModel.TownType").PrimitiveProperty("Id", 1), ProjectionString = "TestModel.CityType/NavProp1", }, new ProjectionTestCase { DebugDescription = "$select=TestModel.CityType/NavProp1 on derived type => specific property templatized.", PayloadEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1), ExpectedEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).NavigationProperty("NavProp1", /*url*/null), ProjectionString = "TestModel.CityType/NavProp1", }, #endregion $select=TestModel.CityType/NavProp1 #region $select=TestModel.TownType/NavProp1 new ProjectionTestCase { DebugDescription = "$select=TestModel.TownType/NavProp1 on base type => specific property templatized..", PayloadEntity = PayloadBuilder.Entity("TestModel.TownType").PrimitiveProperty("Id", 1), ExpectedEntity = PayloadBuilder.Entity("TestModel.TownType").PrimitiveProperty("Id", 1).NavigationProperty("NavProp1", /*url*/null), ProjectionString = "TestModel.TownType/NavProp1", }, new ProjectionTestCase { DebugDescription = "$select=TestModel.TownType/NavProp1 on derived type => specific property templatized.", PayloadEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1), ExpectedEntity = PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 1).NavigationProperty("NavProp1", /*url*/null), ProjectionString = "TestModel.TownType/NavProp1", }, #endregion $select=TestModel.TownType/NavProp1 #region $select=NavProp1/TestModel.City/NavProp2 new ProjectionTestCase { DebugDescription = "$select=NavProp1/TestModel.TownType/NavProp2 on expanded base type => no templatized property.", PayloadEntity = PayloadBuilder.Entity("TestModel.TownType").PrimitiveProperty("Id", 1).ExpandedNavigationProperty("NavProp1", PayloadBuilder.Entity("TestModel.TownType").PrimitiveProperty("Id", 2)), ExpectedEntity = PayloadBuilder.Entity("TestModel.TownType").PrimitiveProperty("Id", 1).ExpandedNavigationProperty("NavProp1", PayloadBuilder.Entity("TestModel.TownType").PrimitiveProperty("Id", 2)), ProjectionString = "NavProp1/TestModel.TownType/NavProp2", }, new ProjectionTestCase { DebugDescription = "$select=NavProp1/TestModel.TownType/NavProp2 on expanded derived type type => specific templatized property.", PayloadEntity = PayloadBuilder.Entity("TestModel.TownType").PrimitiveProperty("Id", 1).ExpandedNavigationProperty("NavProp1", PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 2)), ExpectedEntity = PayloadBuilder.Entity("TestModel.TownType").PrimitiveProperty("Id", 1).ExpandedNavigationProperty("NavProp1", PayloadBuilder.Entity("TestModel.CityType").PrimitiveProperty("Id", 2).NavigationProperty("NavProp2", /*url*/null)), ProjectionString = "NavProp1/TestModel.TownType/NavProp2", }, new ProjectionTestCase { DebugDescription = "$select=TestModel.CityType/* on different derived type => no templatized properties.", PayloadEntity = PayloadBuilder.Entity("TestModel.TownType").PrimitiveProperty("Id", 1).ExpandedNavigationProperty("NavProp1", PayloadBuilder.Entity("TestModel.DuplicateCityType").PrimitiveProperty("Id", 2)), ExpectedEntity = PayloadBuilder.Entity("TestModel.TownType").PrimitiveProperty("Id", 1).ExpandedNavigationProperty("NavProp1", PayloadBuilder.Entity("TestModel.DuplicateCityType").PrimitiveProperty("Id", 2)), ProjectionString = "TestModel.CityType/*", }, #endregion $select=NavProp1/TestModel.City/NavProp2 }; IEnumerable<PayloadReaderTestDescriptor> testDescriptors = testCases.Select(testCase => new PayloadReaderTestDescriptor(this.Settings) { DebugDescription = testCase.DebugDescription, PayloadEdmModel = model, PayloadElement = testCase.PayloadEntity .WithContextUriProjection(testCase.ProjectionString) .ExpectedEntityType(townType, townsSet), ExpectedResultPayloadElement = tc => testCase.ExpectedEntity, ExpectedException = testCase.ExpectedException, }); this.CombinatorialEngineProvider.RunCombinations( testDescriptors, this.ReaderTestConfigurationProvider.JsonLightFormatConfigurations.Where(tc => !tc.IsRequest), (testDescriptor, testConfiguration) => { // These descriptors are already tailored specifically for Json Light and // do not require normalization. testDescriptor.TestDescriptorNormalizers.Clear(); testDescriptor.RunTest(testConfiguration); }); }