public void BuildRelativeUri_AliasInFilterPathSegment_AliasAsBoolean() { Uri relativeUri = new Uri("People/$filter(@p1)?@p1=true", UriKind.Relative); ODataUriParser odataUriParser = new ODataUriParser(HardCodedTestModel.TestModel, serviceRoot, relativeUri); SetODataUriParserSettingsTo(this.settings, odataUriParser.Settings); odataUriParser.UrlKeyDelimiter = ODataUrlKeyDelimiter.Parentheses; ODataUri odataUri = odataUriParser.ParseUri(); List <FilterSegment> filterSegments = odataUri.Path.OfType <FilterSegment>().ToList(); Assert.Single(filterSegments); Assert.Equal(HardCodedTestModel.GetPersonType().ToString(), filterSegments[0].TargetEdmType.ToString()); Assert.False(filterSegments[0].SingleResult); filterSegments[0].Expression.ShouldBeParameterAliasNode("@p1", EdmCoreModel.Instance.GetBoolean(false)); Assert.Null(odataUri.Filter); odataUri.ParameterAliasNodes["@p1"].ShouldBeConstantQueryNode(true); Uri actualUri = odataUri.BuildUri(ODataUrlKeyDelimiter.Parentheses); Assert.Equal(new Uri("http://gobbledygook/People/$filter(@p1)?@p1=true"), actualUri); actualUri = odataUri.BuildUri(ODataUrlKeyDelimiter.Slash); Assert.Equal(new Uri("http://gobbledygook/People/$filter(@p1)?@p1=true"), actualUri); }
public void BuildPath_AliasInFunctionImport_enum() { Uri fullUri = new Uri("http://gobbledygook/GetPetCount(colorPattern=@p1)?@p1=Fully.Qualified.Namespace.ColorPattern'BlueYellowStriped'"); ODataUriParser odataUriParser = new ODataUriParser(HardCodedTestModel.TestModel, serviceRoot, fullUri); SetODataUriParserSettingsTo(this.settings, odataUriParser.Settings); odataUriParser.UrlKeyDelimiter = ODataUrlKeyDelimiter.Parentheses; ODataUri odataUri = odataUriParser.ParseUri(); IDictionary <string, SingleValueNode> aliasNodes = odataUri.ParameterAliasNodes; OperationSegmentParameter p = odataUri.Path.LastSegment.ShouldBeOperationImportSegment(HardCodedTestModel.GetFunctionImportForGetPetCount()).And.Parameters.First(); p.Name.Should().Be("colorPattern"); p.Value.As <ParameterAliasNode>().Alias.Should().Be("@p1"); p.Value.As <ParameterAliasNode>().TypeReference.IsEnum().Should().Be(true); p.Value.As <ParameterAliasNode>().TypeReference.Definition.FullTypeName().ShouldBeEquivalentTo("Fully.Qualified.Namespace.ColorPattern"); aliasNodes["@p1"].As <ConstantNode>().Value.As <ODataEnumValue>().TypeName.Should().Be("Fully.Qualified.Namespace.ColorPattern"); aliasNodes["@p1"].As <ConstantNode>().Value.As <ODataEnumValue>().Value.Should().Be("22"); aliasNodes["@p1"].TypeReference.IsEnum().Should().Be(true); Uri actualUri = odataUri.BuildUri(ODataUrlKeyDelimiter.Parentheses); Assert.Equal(fullUri, actualUri); actualUri = odataUri.BuildUri(ODataUrlKeyDelimiter.Slash); Assert.Equal(fullUri, actualUri); }
public void BuildFilter_AliasInFunction_WithoutValue() { Uri fullUri = new Uri("http://gobbledygook/People?$filter=Fully.Qualified.Namespace.HasDog(inOffice%3D%40p1%2Cname%3D%40p2)"); ODataUriParser odataUriParser = new ODataUriParser(HardCodedTestModel.TestModel, serviceRoot, fullUri); SetODataUriParserSettingsTo(this.settings, odataUriParser.Settings); odataUriParser.UrlKeyDelimiter = ODataUrlKeyDelimiter.Parentheses; ODataUri odataUri = odataUriParser.ParseUri(); IDictionary <string, SingleValueNode> aliasNodes = odataUri.ParameterAliasNodes; var function = HardCodedTestModel.GetHasDogOverloadForPeopleWithThreeParameters() as IEdmFunction; Assert.NotNull(function); var functionCallNode = odataUri.Filter.Expression.ShouldBeSingleValueFunctionCallQueryNode(function); Assert.IsType <NamedFunctionParameterNode>(functionCallNode.Parameters.Last()).Value.ShouldBeParameterAliasNode("@p2", null); Assert.Null(aliasNodes["@p1"]); Assert.Null(aliasNodes["@p2"]); Uri actualUri = odataUri.BuildUri(ODataUrlKeyDelimiter.Parentheses); Assert.Equal(fullUri, actualUri); actualUri = odataUri.BuildUri(ODataUrlKeyDelimiter.Slash); Assert.Equal(fullUri, actualUri); }
public void BuildRelativeUri_FilterSegmentWithAliasInFilterOption_AliasAsBoolean() { Uri relativeUri = new Uri("People/$filter(ID%20eq%201)?$filter=%40p1&@p1=true", UriKind.Relative); ODataUriParser odataUriParser = new ODataUriParser(HardCodedTestModel.TestModel, serviceRoot, relativeUri); SetODataUriParserSettingsTo(this.settings, odataUriParser.Settings); odataUriParser.UrlKeyDelimiter = ODataUrlKeyDelimiter.Parentheses; ODataUri odataUri = odataUriParser.ParseUri(); List <FilterSegment> filterSegments = odataUri.Path.OfType <FilterSegment>().ToList(); Assert.Single(filterSegments); Assert.Equal(HardCodedTestModel.GetPersonType().ToString(), filterSegments[0].TargetEdmType.ToString()); Assert.False(filterSegments[0].SingleResult); BinaryOperatorNode binaryOperatorNode = filterSegments[0].Expression as BinaryOperatorNode; Assert.NotNull(binaryOperatorNode); Assert.Equal(BinaryOperatorKind.Equal, binaryOperatorNode.OperatorKind); binaryOperatorNode.Left.ShouldBeSingleValuePropertyAccessQueryNode(HardCodedTestModel.GetPersonIdProp()); binaryOperatorNode.Right.ShouldBeConstantQueryNode(1); odataUri.Filter.Expression.ShouldBeParameterAliasNode("@p1", EdmCoreModel.Instance.GetBoolean(false)); odataUri.ParameterAliasNodes["@p1"].ShouldBeConstantQueryNode(true); Uri expectedUri = new Uri("http://gobbledygook/People/$filter(ID%20eq%201)?$filter=%40p1&@p1=true"); Uri actualUri = odataUri.BuildUri(ODataUrlKeyDelimiter.Parentheses); Assert.Equal(expectedUri, actualUri); actualUri = odataUri.BuildUri(ODataUrlKeyDelimiter.Slash); Assert.Equal(expectedUri, actualUri); }
public void BuildFilter_AliasInFunction_PropertyAsValue_TypeMismatch() { Uri fullUri = new Uri("http://gobbledygook/People?$filter=Fully.Qualified.Namespace.HasDog(inOffice%3D%40p1%2Cname%3D%40p1)&@p2=Name&@p1=%40p2"); ODataUriParser odataUriParser = new ODataUriParser(HardCodedTestModel.TestModel, serviceRoot, fullUri); SetODataUriParserSettingsTo(this.settings, odataUriParser.Settings); odataUriParser.UrlKeyDelimiter = ODataUrlKeyDelimiter.Parentheses; ODataUri odataUri = odataUriParser.ParseUri(); IDictionary <string, SingleValueNode> aliasNodes = odataUri.ParameterAliasNodes; IEdmFunction function = HardCodedTestModel.GetHasDogOverloadForPeopleWithThreeParameters() as IEdmFunction; Assert.NotNull(function); var functionCallNode = odataUri.Filter.Expression.ShouldBeSingleValueFunctionCallQueryNode(function); Assert.IsType <NamedFunctionParameterNode>(functionCallNode.Parameters.Last()).Value.ShouldBeParameterAliasNode("@p1", EdmCoreModel.Instance.GetString(true)); aliasNodes["@p1"].ShouldBeParameterAliasNode("@p2", EdmCoreModel.Instance.GetString(true)); aliasNodes["@p2"].ShouldBeSingleValuePropertyAccessQueryNode(HardCodedTestModel.GetPeopleSet().EntityType().FindProperty("Name")); Uri actualUri = odataUri.BuildUri(ODataUrlKeyDelimiter.Parentheses); Assert.Equal(fullUri, actualUri); actualUri = odataUri.BuildUri(ODataUrlKeyDelimiter.Slash); Assert.Equal(fullUri, actualUri); }
public void BuildFilter_AliasInFunction_enum() { Uri fullUri = new Uri("http://gobbledygook/People?$filter=null%20ne%20Fully.Qualified.Namespace.GetPetCount(colorPattern%3D%40p1)&@p1=Fully.Qualified.Namespace.ColorPattern'BlueYellowStriped'"); ODataUriParser odataUriParser = new ODataUriParser(HardCodedTestModel.TestModel, serviceRoot, fullUri); SetODataUriParserSettingsTo(this.settings, odataUriParser.Settings); odataUriParser.UrlKeyDelimiter = ODataUrlKeyDelimiter.Parentheses; ODataUri odataUri = odataUriParser.ParseUri(); var rightNode = Assert.IsType <BinaryOperatorNode>(odataUri.Filter.Expression).Right; NamedFunctionParameterNode p = Assert.IsType <NamedFunctionParameterNode>(Assert.IsType <SingleResourceFunctionCallNode>(rightNode).Parameters.First()); ParameterAliasNode aliasNode = Assert.IsType <ParameterAliasNode>(p.Value); Assert.Equal("@p1", aliasNode.Alias); Assert.True(aliasNode.TypeReference.IsEnum()); Assert.Equal("Fully.Qualified.Namespace.ColorPattern", aliasNode.TypeReference.Definition.FullTypeName()); IDictionary <string, SingleValueNode> aliasNodes = odataUri.ParameterAliasNodes; var node = Assert.IsType <ConstantNode>(aliasNodes["@p1"]); var enumValue = Assert.IsType <ODataEnumValue>(node.Value); Assert.Equal("Fully.Qualified.Namespace.ColorPattern", enumValue.TypeName); Assert.Equal("22", enumValue.Value); Assert.True(aliasNodes["@p1"].TypeReference.IsEnum()); Uri actualUri = odataUri.BuildUri(ODataUrlKeyDelimiter.Parentheses); Assert.Equal(fullUri, actualUri); actualUri = odataUri.BuildUri(ODataUrlKeyDelimiter.Slash); Assert.Equal(fullUri, actualUri); }
public void BuildFilter_AliasInFunction() { Uri fullUri = new Uri("http://gobbledygook/People?$filter=Fully.Qualified.Namespace.AllHaveDog(inOffice%3D%40p1)&@p1=true"); ODataUriParser odataUriParser = new ODataUriParser(HardCodedTestModel.TestModel, serviceRoot, fullUri); SetODataUriParserSettingsTo(this.settings, odataUriParser.Settings); odataUriParser.UrlKeyDelimiter = ODataUrlKeyDelimiter.Parentheses; ODataUri odataUri = odataUriParser.ParseUri(); IDictionary <string, SingleValueNode> aliasNodes = odataUri.ParameterAliasNodes; var functionCallNode = odataUri.Filter.Expression.ShouldBeSingleValueFunctionCallQueryNode(HardCodedTestModel.GetFunctionForAllHaveDogWithTwoParameters()); var queryNode = Assert.IsType <NamedFunctionParameterNode>(functionCallNode.Parameters.Last()).Value; queryNode.ShouldBeParameterAliasNode("@p1", EdmCoreModel.Instance.GetBoolean(false)); aliasNodes["@p1"].ShouldBeConstantQueryNode(true); Uri actualUri = odataUri.BuildUri(ODataUrlKeyDelimiter.Parentheses); Assert.Equal(fullUri, actualUri); actualUri = odataUri.BuildUri(ODataUrlKeyDelimiter.Slash); Assert.Equal(fullUri, actualUri); }
public void BuildFilter_AliasInFunction_enum_undefined() { Uri fullUri = new Uri("http://gobbledygook/People?$filter=null%20ne%20Fully.Qualified.Namespace.GetPetCount(colorPattern%3D%40p1)&@p1=Fully.Qualified.Namespace.ColorPattern'238563'"); ODataUriParser odataUriParser = new ODataUriParser(HardCodedTestModel.TestModel, serviceRoot, fullUri); SetODataUriParserSettingsTo(this.settings, odataUriParser.Settings); odataUriParser.UrlKeyDelimiter = ODataUrlKeyDelimiter.Parentheses; ODataUri odataUri = odataUriParser.ParseUri(); NamedFunctionParameterNode p = odataUri.Filter.Expression.As <BinaryOperatorNode>().Right.As <SingleResourceFunctionCallNode>().Parameters.First().As <NamedFunctionParameterNode>(); p.Value.As <ParameterAliasNode>().Alias.ShouldBeEquivalentTo("@p1"); p.Value.As <ParameterAliasNode>().TypeReference.IsEnum().Should().Be(true); p.Value.As <ParameterAliasNode>().TypeReference.Definition.FullTypeName().ShouldBeEquivalentTo("Fully.Qualified.Namespace.ColorPattern"); IDictionary <string, SingleValueNode> aliasNodes = odataUri.ParameterAliasNodes; aliasNodes["@p1"].As <ConstantNode>().Value.As <ODataEnumValue>().TypeName.Should().Be("Fully.Qualified.Namespace.ColorPattern"); aliasNodes["@p1"].As <ConstantNode>().Value.As <ODataEnumValue>().Value.Should().Be("238563"); aliasNodes["@p1"].TypeReference.IsEnum().Should().Be(true); Uri actualUri = odataUri.BuildUri(ODataUrlKeyDelimiter.Parentheses); Assert.Equal(fullUri, actualUri); actualUri = odataUri.BuildUri(ODataUrlKeyDelimiter.Slash); Assert.Equal(fullUri, actualUri); }
public Uri GetNextPageLinkRoot(OeEntryFactory entryFactory, int readCount, int?totalCount, Object value) { if (readCount == 0) { return(null); } int pageSize = GetPageSizeRoot(); if (pageSize == 0) { return(null); } int restCount = GetRestCountRoot(readCount, totalCount); if (restCount == 0) { return(null); } ODataUri nextOdataUri = _queryContext.ODataUri.Clone(); nextOdataUri.SelectAndExpand = _queryContext.ODataUri.SelectAndExpand; nextOdataUri.ServiceRoot = null; nextOdataUri.QueryCount = null; nextOdataUri.Top = pageSize; nextOdataUri.Skip = null; nextOdataUri.SkipToken = OeSkipTokenParser.GetSkipToken(_queryContext.EdmModel, entryFactory.SkipTokenAccessors, value, restCount); return(nextOdataUri.BuildUri(ODataUrlKeyDelimiter.Parentheses)); }
public IEnumerable<T> Resolve(ResolveFieldContext context) { var zzz3 = context.ParentType.Fields.Single(f => f.Name == context.Document.Operations.Single().SelectionSet.Selections.OfType<Field>().Single().Name); var zzz = context.Schema.FindType("order"); var zzz2 = context.Schema.Query.Fields.Single(f => f.Name == context.FieldAst.Name); var barcode = context.GetArgument<string>("barcode"); var title = context.GetArgument<string>("title"); var sellingPrice = context.GetArgument<decimal>("sellingPrice"); var results = new List<T>(); var odataParser = new ODataUriParser(_edmModel, new Uri("http://dummy"), new Uri("http://dummy/Orders?$expand=Customer&$select=Name")); odataParser.Resolver.EnableCaseInsensitive = true; //ODataUri odataUri = odataParser.ParseUri(); var translator = new OeGraphQLAstToODataUri(_edmModel, context.Schema); ODataUri odataUri = translator.Translate(context.Document.OriginalQuery); var odataQuery = odataUri.BuildUri(ODataUrlKeyDelimiter.Parentheses); var parser = new OeGetParser(_dataAdapter, _edmModel); Parsers.OeQueryContext queryContext = parser.CreateQueryContext(odataUri, 0, false, OeMetadataLevel.Minimal); Db.OeAsyncEnumerator asyncEnumerator = _dataAdapter.ExecuteEnumerator(context.UserContext, queryContext, CancellationToken.None); using (var entityAsyncEnumerator = new OeEntityAsyncEnumerator<T>(queryContext.EntryFactory, asyncEnumerator, queryContext)) { while (entityAsyncEnumerator.MoveNext().GetAwaiter().GetResult()) results.Add((T)entityAsyncEnumerator.Current); } return results; }
public async Task NavigationNextLink() { String request = "Categories?$expand=Children"; OeParser parser = Fixture.CreateParser(request, Fixture.ModelBoundProvider); ODataUri odataUri = Fixture.ParseUri(request); var response = new MemoryStream(); await parser.ExecuteQueryAsync(odataUri, OeRequestHeaders.JsonDefault, response, CancellationToken.None).ConfigureAwait(false); response.Position = 0; var reader = new ResponseReader(parser.EdmModel); List <Object> categories = reader.Read(response).Cast <Object>().ToList(); foreach (dynamic category in categories) { ResponseReader.NavigationInfo navigationInfo = reader.GetNavigationInfo(category.Children); String actual = Uri.UnescapeDataString(navigationInfo.NextPageLink.OriginalString); String expected = $"http://dummy/Categories?$filter=ParentId eq {category.Id}&$select=DateTime,Id,Name,ParentId"; ODataUri actualOdataUri = Fixture.ParseUri(actual); var selectedItems = actualOdataUri.SelectAndExpand.SelectedItems.Cast <PathSelectItem>().OrderBy(i => ((PropertySegment)i.SelectedPath.FirstSegment).Property.Name); actualOdataUri.SelectAndExpand = new SelectExpandClause(selectedItems, actualOdataUri.SelectAndExpand.AllSelected); actual = Uri.UnescapeDataString(actualOdataUri.BuildUri(ODataUrlKeyDelimiter.Parentheses).OriginalString); Assert.Equal(expected, actual); } }
public static Uri UriBuilder(Uri queryUri, ODataUrlKeyDelimiter urlKeyDelimiter, ODataUriParserSettings settings) { ODataUriParser odataUriParser = new ODataUriParser(HardCodedTestModel.TestModel, ServiceRoot, queryUri); odataUriParser.UrlKeyDelimiter = urlKeyDelimiter; ODataUri odataUri = odataUriParser.ParseUri(); return(odataUri.BuildUri(urlKeyDelimiter)); }
public void BuildUrlWithApply(string query) { var parser = new ODataUriParser(HardCodedTestModel.TestModel, ServiceRoot, new Uri(query)); ODataUri odataUri = parser.ParseUri(); Uri result = odataUri.BuildUri(ODataUrlKeyDelimiter.Parentheses); Assert.Equal(query, Uri.UnescapeDataString(result.OriginalString)); }
public void TrailingDollarSegmentIsIgnored() { Uri queryUri = new Uri("People/$", UriKind.Relative); ODataUriParser odataUriParser = new ODataUriParser(HardCodedTestModel.TestModel, new Uri("https://www.blah.org/OData/"), queryUri); ODataUri odataUri = odataUriParser.ParseUri(); Uri actualUri = odataUri.BuildUri(ODataUrlKeyDelimiter.Parentheses); Assert.Equal(new Uri("https://www.blah.org/OData/People"), actualUri); }
public void UriOverloadSmokeTest() { Uri queryUri = new Uri("Dogs", UriKind.Relative); ODataUriParser odataUriParser = new ODataUriParser(HardCodedTestModel.TestModel, new Uri("https://www.tomatosoup.com:1234/OData/V3/"), queryUri); ODataUri odataUri = odataUriParser.ParseUri(); Uri actualUri = odataUri.BuildUri(ODataUrlKeyDelimiter.Parentheses); Assert.Equal(new Uri("https://www.tomatosoup.com:1234/OData/V3/Dogs"), actualUri); }
public void BuildPathWithRelativeFullUri() { Uri queryUri = new Uri("Dogs", UriKind.Relative); ODataUriParser odataUriParser = new ODataUriParser(HardCodedTestModel.TestModel, new Uri("http://gobbldygook/service.svc"), queryUri); ODataUri odataUri = odataUriParser.ParseUri(); Uri actualUri = odataUri.BuildUri(ODataUrlKeyDelimiter.Parentheses); Assert.Equal(new Uri("http://gobbldygook/service.svc/Dogs"), actualUri); }
public Uri GetOdataUri(String query) { var context = new ResolveFieldContext() { Schema = Schema }; var translator = new OeGraphqlAstToODataUri(EdmModel, context); ODataUri odataUri = translator.Translate(query); return(odataUri.BuildUri(ODataUrlKeyDelimiter.Parentheses)); }
private Uri BuildNextPageLink(String skipToken) { ODataUri nextOdataUri = _odataUri.Clone(); nextOdataUri.ServiceRoot = null; nextOdataUri.QueryCount = null; nextOdataUri.Top = PageSize; nextOdataUri.Skip = null; nextOdataUri.SkipToken = skipToken; return(nextOdataUri.BuildUri(ODataUrlKeyDelimiter.Parentheses)); }
public void BuildOrderby_AliasInBinaryOp() { Uri fullUri = new Uri("http://gobbledygook/People?$orderby=ID%20mul%20%40p1%20asc&@p1=3 div 2"); ODataUriParser odataUriParser = new ODataUriParser(HardCodedTestModel.TestModel, serviceRoot, fullUri); SetODataUriParserSettingsTo(this.settings, odataUriParser.Settings); odataUriParser.UrlKeyDelimiter = ODataUrlKeyDelimiter.Parentheses; ODataUri odataUri = odataUriParser.ParseUri(); IDictionary <string, SingleValueNode> aliasNodes = odataUri.ParameterAliasNodes; odataUri.OrderBy.Expression.ShouldBeBinaryOperatorNode(BinaryOperatorKind.Multiply).And.Right.ShouldBeParameterAliasNode("@p1", EdmCoreModel.Instance.GetInt32(false)); aliasNodes["@p1"].ShouldBeBinaryOperatorNode(BinaryOperatorKind.Divide).And.Right.ShouldBeConstantQueryNode(2); Uri actualUri = odataUri.BuildUri(ODataUrlKeyDelimiter.Parentheses); Assert.Equal(new Uri("http://gobbledygook/People?$orderby=ID%20mul%20%40p1&@p1=3 div 2"), actualUri); actualUri = odataUri.BuildUri(ODataUrlKeyDelimiter.Slash); Assert.Equal(new Uri("http://gobbledygook/People?$orderby=ID%20mul%20%40p1&@p1=3 div 2"), actualUri); }
public void BuildFilter_AliasInFunction_BuiltIn() { Uri fullUri = new Uri("http://gobbledygook/People?$filter=contains(%40p1%2CName)&@p1=Name"); ODataUriParser odataUriParser = new ODataUriParser(HardCodedTestModel.TestModel, serviceRoot, fullUri); SetODataUriParserSettingsTo(this.settings, odataUriParser.Settings); odataUriParser.UrlKeyDelimiter = ODataUrlKeyDelimiter.Parentheses; ODataUri odataUri = odataUriParser.ParseUri(); IDictionary <string, SingleValueNode> aliasNodes = odataUri.ParameterAliasNodes; odataUri.Filter.Expression.As <SingleValueFunctionCallNode>().Parameters.First().ShouldBeParameterAliasNode("@p1", EdmCoreModel.Instance.GetString(true)); aliasNodes["@p1"].ShouldBeSingleValuePropertyAccessQueryNode(HardCodedTestModel.GetPeopleSet().EntityType().FindProperty("Name")); Uri actualUri = odataUri.BuildUri(ODataUrlKeyDelimiter.Parentheses); Assert.Equal(fullUri, actualUri); actualUri = odataUri.BuildUri(ODataUrlKeyDelimiter.Slash); Assert.Equal(fullUri, actualUri); }
public void BuildPath_AliasInFunctionImport() { Uri fullUri = new Uri("http://gobbledygook/GetPet4(id=@p1)?@p1=1.01M"); ODataUriParser odataUriParser = new ODataUriParser(HardCodedTestModel.TestModel, serviceRoot, fullUri); SetODataUriParserSettingsTo(this.settings, odataUriParser.Settings); odataUriParser.UrlKeyDelimiter = ODataUrlKeyDelimiter.Parentheses; ODataUri odataUri = odataUriParser.ParseUri(); IDictionary <string, SingleValueNode> aliasNodes = odataUri.ParameterAliasNodes; odataUri.Path.LastSegment.ShouldBeOperationImportSegment(HardCodedTestModel.GetFunctionImportForGetPet4()).And.Parameters.First().ShouldHaveParameterAliasNode("id", "@p1", EdmCoreModel.Instance.GetDecimal(false)); aliasNodes["@p1"].ShouldBeConstantQueryNode(1.01M); Uri actualUri = odataUri.BuildUri(ODataUrlKeyDelimiter.Parentheses); Assert.Equal(fullUri, actualUri); actualUri = odataUri.BuildUri(ODataUrlKeyDelimiter.Slash); Assert.Equal(fullUri, actualUri); }
public void BuildPath_AliasInBoundFunction() { Uri fullUri = new Uri("http://gobbledygook/People(123)/Fully.Qualified.Namespace.HasHat(onCat=@p1)?@p1=true"); ODataUriParser odataUriParser = new ODataUriParser(HardCodedTestModel.TestModel, serviceRoot, fullUri); SetODataUriParserSettingsTo(this.settings, odataUriParser.Settings); odataUriParser.UrlKeyDelimiter = ODataUrlKeyDelimiter.Parentheses; ODataUri odataUri = odataUriParser.ParseUri(); IDictionary <string, SingleValueNode> aliasNodes = odataUri.ParameterAliasNodes; odataUri.Path.LastSegment.ShouldBeOperationSegment(HardCodedTestModel.TestModel.FindOperations("Fully.Qualified.Namespace.HasHat").Single(s => (s as IEdmFunction).Parameters.Count() == 2)).As <IEdmFunction>(); aliasNodes["@p1"].ShouldBeConstantQueryNode(true); Uri actualUri = odataUri.BuildUri(ODataUrlKeyDelimiter.Parentheses); Assert.Equal(fullUri, actualUri); actualUri = odataUri.BuildUri(ODataUrlKeyDelimiter.Slash); Assert.NotEqual(fullUri, actualUri); }
public void BuildFilter_AliasInBinaryOp_ValueAsExpression() { Uri fullUri = new Uri("http://gobbledygook/People?$filter=ID%20eq%20%40p1&@p1=1 add 2"); ODataUriParser odataUriParser = new ODataUriParser(HardCodedTestModel.TestModel, serviceRoot, fullUri); SetODataUriParserSettingsTo(this.settings, odataUriParser.Settings); odataUriParser.UrlKeyDelimiter = ODataUrlKeyDelimiter.Parentheses; ODataUri odataUri = odataUriParser.ParseUri(); IDictionary <string, SingleValueNode> aliasNodes = odataUri.ParameterAliasNodes; odataUri.Filter.Expression.ShouldBeBinaryOperatorNode(BinaryOperatorKind.Equal).And.Right.ShouldBeParameterAliasNode("@p1", EdmCoreModel.Instance.GetInt32(false)); aliasNodes["@p1"].ShouldBeBinaryOperatorNode(BinaryOperatorKind.Add).And.Right.ShouldBeConstantQueryNode(2); Uri actualUri = odataUri.BuildUri(ODataUrlKeyDelimiter.Parentheses); Assert.Equal(fullUri, actualUri); actualUri = odataUri.BuildUri(ODataUrlKeyDelimiter.Slash); Assert.Equal(fullUri, actualUri); }
private static Uri BuildNextPageLink(OeQueryContext queryContext, Object value) { ODataUri nextOdataUri = queryContext.ODataUri.Clone(); nextOdataUri.ServiceRoot = null; nextOdataUri.QueryCount = null; nextOdataUri.Top = queryContext.PageSize; nextOdataUri.Skip = null; nextOdataUri.SkipToken = OeSkipTokenParser.GetSkipToken(queryContext.EdmModel, queryContext.SkipTokenAccessors, value); return(nextOdataUri.BuildUri(ODataUrlKeyDelimiter.Parentheses)); }
public void BuildUrlWithDeltaTokenODataUri() { ODataUri uri = new ODataUri(); uri.ServiceRoot = new Uri("http://gobbledygook/"); uri.DeltaToken = "MyToken"; uri.Path = new ODataPath(new EntitySetSegment(HardCodedTestModel.GetPeopleSet())); Assert.Equal(uri.ParameterAliasNodes.Count, 0); Uri res = uri.BuildUri(ODataUrlKeyDelimiter.Parentheses); Assert.Equal(new Uri("http://gobbledygook/People?$deltatoken=MyToken"), res); }
public void BuildOrderby_AliasInFunction() { Uri fullUri = new Uri("http://gobbledygook/People?$orderby=Fully.Qualified.Namespace.HasDog(inOffice%3D%40p1)&@p1=true"); ODataUriParser odataUriParser = new ODataUriParser(HardCodedTestModel.TestModel, serviceRoot, fullUri); SetODataUriParserSettingsTo(this.settings, odataUriParser.Settings); odataUriParser.UrlKeyDelimiter = ODataUrlKeyDelimiter.Parentheses; ODataUri odataUri = odataUriParser.ParseUri(); IDictionary <string, SingleValueNode> aliasNodes = odataUri.ParameterAliasNodes; var expectedFunc = HardCodedTestModel.GetAllHasDogFunctionOverloadsForPeople().Single(s => s.Parameters.Count() == 2); odataUri.OrderBy.Expression.ShouldBeSingleValueFunctionCallQueryNode(expectedFunc).And.Parameters.Last().As <NamedFunctionParameterNode>().Value.ShouldBeParameterAliasNode("@p1", EdmCoreModel.Instance.GetBoolean(false)); aliasNodes["@p1"].ShouldBeConstantQueryNode(true); Uri actualUri = odataUri.BuildUri(ODataUrlKeyDelimiter.Parentheses); Assert.Equal(fullUri, actualUri); actualUri = odataUri.BuildUri(ODataUrlKeyDelimiter.Slash); Assert.Equal(fullUri, actualUri); }
public void BuildExpandOrderby_AliasInFunction() { Uri fullUri = new Uri("http://gobbledygook/People?$expand=MyPet2Set($orderby=concat(Color, @p1 )asc )&@p1='abc'"); ODataUriParser odataUriParser = new ODataUriParser(HardCodedTestModel.TestModel, serviceRoot, fullUri); SetODataUriParserSettingsTo(this.settings, odataUriParser.Settings); odataUriParser.UrlKeyDelimiter = ODataUrlKeyDelimiter.Parentheses; ODataUri odataUri = odataUriParser.ParseUri(); IDictionary <string, SingleValueNode> aliasNodes = odataUri.ParameterAliasNodes; SingleValueFunctionCallNode node = (odataUri.SelectAndExpand.SelectedItems.First() as ExpandedNavigationSelectItem).OrderByOption.Expression as SingleValueFunctionCallNode; node.Parameters.Last().ShouldBeParameterAliasNode("@p1", EdmCoreModel.Instance.GetString(true)); aliasNodes["@p1"].ShouldBeConstantQueryNode("abc"); Uri actualUri = odataUri.BuildUri(ODataUrlKeyDelimiter.Parentheses); Assert.Equal("http://gobbledygook/People?$expand=" + Uri.EscapeDataString("MyPet2Set($orderby=concat(Color,@p1))") + "&@p1=" + Uri.EscapeDataString("'abc'"), actualUri.OriginalString); actualUri = odataUri.BuildUri(ODataUrlKeyDelimiter.Slash); Assert.Equal("http://gobbledygook/People?$expand=" + Uri.EscapeDataString("MyPet2Set($orderby=concat(Color,@p1))") + "&@p1=" + Uri.EscapeDataString("'abc'"), actualUri.OriginalString); }
public void RelativeUriBuildWithEmptyQueryOptions() { Uri queryUri = new Uri("People", UriKind.Relative); ODataUriParser odataUriParser = new ODataUriParser(this.GetModel(), queryUri); SetODataUriParserSettingsTo(this.settings, odataUriParser.Settings); odataUriParser.UrlKeyDelimiter = ODataUrlKeyDelimiter.Parentheses; ODataUri odataUri = odataUriParser.ParseUri(); Uri actualUri = odataUri.BuildUri(ODataUrlKeyDelimiter.Parentheses); Assert.AreEqual(queryUri, actualUri); }
public void AbsoluteUriBuildWithEmptyQueryOptions() { Uri queryUri = new Uri("http://www.example.com/People"); ODataUriParser odataUriParser = new ODataUriParser(this.GetModel(), serviceRoot, queryUri); SetODataUriParserSettingsTo(this.settings, odataUriParser.Settings); odataUriParser.UrlKeyDelimiter = ODataUrlKeyDelimiter.Parentheses; ODataUri odataUri = odataUriParser.ParseUri(); Uri actualUri = odataUri.BuildUri(ODataUrlKeyDelimiter.Parentheses); Assert.AreEqual(queryUri, actualUri); }
public void BuildUrlWithNewODataUri() { ODataUri uri = new ODataUri(); uri.ServiceRoot = new Uri("http://gobbledygook/"); uri.Skip = 4; uri.Top = 5; uri.Path = new ODataPath(new EntitySetSegment(HardCodedTestModel.GetPeopleSet())); Assert.Empty(uri.ParameterAliasNodes); Uri res = uri.BuildUri(ODataUrlKeyDelimiter.Parentheses); Assert.Equal(new Uri("http://gobbledygook/People?$top=5&$skip=4"), res); }