public void ParsePathShouldWork() { var path = new ODataUriParser(HardCodedTestModel.TestModel, new Uri("People", UriKind.Relative)).ParsePath(); path.Should().HaveCount(1); path.LastSegment.ShouldBeEntitySetSegment(HardCodedTestModel.GetPeopleSet()); }
public void AlternateKeyShouldWork() { ODataPath pathSegment = new ODataUriParser(HardCodedTestModel.TestModel, new Uri("http://host"), new Uri("http://host/People(SocialSN = \'1\')")) { Resolver = new AlternateKeysODataUriResolver(HardCodedTestModel.TestModel) }.ParsePath(); pathSegment.Should().HaveCount(2); pathSegment.FirstSegment.ShouldBeEntitySetSegment(HardCodedTestModel.TestModel.FindDeclaredEntitySet("People")); pathSegment.LastSegment.ShouldBeKeySegment(new KeyValuePair<string, object>("SocialSN", "1")); }
public void CompositeAlternateKeyShouldWork() { Uri fullUri = new Uri("http://host/People(NameAlias=\'anyName\',FirstNameAlias=\'anyFirst\')"); ODataPath pathSegment = new ODataUriParser(HardCodedTestModel.TestModel, new Uri("http://host"), fullUri) { Resolver = new AlternateKeysODataUriResolver(HardCodedTestModel.TestModel) }.ParsePath(); pathSegment.Should().HaveCount(2); pathSegment.FirstSegment.ShouldBeEntitySetSegment(HardCodedTestModel.TestModel.FindDeclaredEntitySet("People")); pathSegment.LastSegment.ShouldBeKeySegment(new KeyValuePair<string, object>("NameAlias", "anyName"), new KeyValuePair<string, object>("FirstNameAlias", "anyFirst")); }
public void PathThatIsOnlyEscapeSegments() { var path = new ODataUriParser(HardCodedTestModel.TestModel, new Uri("http://gobbldygook/"), new Uri("http://gobbldygook/$/$/$")) { UrlConventions = ODataUrlConventions.KeyAsSegment }.ParsePath(); path.Should().BeEmpty(); }