public void CanParseActionBoundToCollectionSegment() { // Arrange string testUrl = "http://myservice/Customers/System.Web.Http.OData.Routing.VIP/GetMostProfitable"; string expectedText = "Default.Container.GetMostProfitable"; IEdmFunctionImport expectedEdmElement = _parser.Model.EntityContainers().First().FunctionImports().SingleOrDefault(p => p.Name == "GetMostProfitable"); IEdmEntitySet expectedSet = _parser.Model.EntityContainers().First().EntitySets().SingleOrDefault(e => e.Name == "Customers"); IEdmType expectedType = expectedEdmElement.ReturnType.Definition; Uri uri = new Uri(testUrl); Uri baseUri = new Uri("http://myservice/"); // Act ODataPath path = _parser.Parse(uri, baseUri); ODataPathSegment segment = path.Segments.Last.Value; // Assert Assert.NotNull(segment); Assert.NotNull(segment.Previous); Assert.Equal(expectedText, segment.ToString()); Assert.Same(expectedSet, segment.EntitySet); Assert.Same(expectedType, segment.EdmType); ActionPathSegment action = Assert.IsType <ActionPathSegment>(segment); Assert.Same(expectedEdmElement, action.Action); }
public void Parse_WorksOnEncodedCharacters() { string odataPath = "üCategories"; ODataPath path = _parser.Parse(_model, odataPath); ODataPathSegment segment = path.Segments.Last(); Assert.NotNull(path); Assert.Equal("~/entityset", path.PathTemplate); Assert.Equal("üCategories", segment.ToString()); }
public void CanParseMetadataUrl() { string odataPath = "$metadata"; ODataPath path = _parser.Parse(_model, odataPath); ODataPathSegment segment = path.Segments.Last(); // Assert Assert.NotNull(path); Assert.Null(path.EntitySet); Assert.Null(path.EdmType); Assert.Equal("$metadata", segment.ToString()); }
public void CanParseBatchUrl() { // Arrange string odataPath = "$batch"; // Act ODataPath path = _parser.Parse(_model, odataPath); ODataPathSegment segment = path.Segments.Last(); // Assert Assert.NotNull(path); Assert.NotNull(segment); Assert.Null(path.EntitySet); Assert.Null(path.EdmType); Assert.Equal("$batch", segment.ToString()); }
public void CanParsePropertyValueSegment() { // Arrange string odataPath = "RoutingCustomers(1)/Name/$value"; // Act ODataPath path = _parser.Parse(_model, odataPath); ODataPathSegment segment = path.Segments.Last(); // Assert Assert.NotNull(segment); Assert.Equal("$value", segment.ToString()); Assert.Null(path.EntitySet); Assert.NotNull(path.EdmType); Assert.Equal("Edm.String", (path.EdmType as IEdmPrimitiveType).FullName()); }
public void CanParseMetadataUrl() { string testUrl = "http://myservice/$metadata"; Uri uri = new Uri(testUrl); Uri baseUri = new Uri("http://myservice/"); ODataPath path = _parser.Parse(uri, baseUri); ODataPathSegment segment = path.Segments.Last.Value; // Assert Assert.NotNull(path); Assert.Null(path.EntitySet); Assert.Null(path.EdmType); Assert.Equal("$metadata", segment.ToString()); Assert.NotNull(segment.Previous); Assert.Equal("http://myservice/", segment.Previous.ToString()); }
public void CanParsePropertyValueSegment() { // Arrange string testUrl = "http://myservice/Customers(1)/Name/$value"; Uri uri = new Uri(testUrl); Uri baseUri = new Uri("http://myservice/"); // Act ODataPath path = _parser.Parse(uri, baseUri); ODataPathSegment segment = path.Segments.Last.Value; // Assert Assert.NotNull(segment); Assert.Equal("$value", segment.ToString()); Assert.Null(segment.EntitySet); Assert.NotNull(segment.EdmType); Assert.Equal("Edm.String", (segment.EdmType as IEdmPrimitiveType).FullName()); }
public void CanParseKeyUrl() { // Arrange string odataPath = "RoutingCustomers(112)"; string expectedText = "112"; IEdmEntitySet expectedSet = _model.EntityContainers().First().EntitySets().SingleOrDefault(s => s.Name == "RoutingCustomers"); // Act ODataPath path = _parser.Parse(_model, odataPath); ODataPathSegment segment = path.Segments.Last(); // Assert Assert.NotNull(segment); Assert.Equal(expectedText, segment.ToString()); Assert.IsType <KeyValuePathSegment>(segment); Assert.Same(expectedSet, path.EntitySet); Assert.Same(expectedSet.ElementType, path.EdmType); }
public void CanParseCastEntitySegment() { // Arrange string odataPath = "RoutingCustomers(100)/System.Web.Http.OData.Routing.VIP"; string expectedText = "System.Web.Http.OData.Routing.VIP"; IEdmEntitySet expectedSet = _model.EntityContainers().First().EntitySets().SingleOrDefault(s => s.Name == "RoutingCustomers"); IEdmEntityType expectedType = _model.SchemaElements.OfType <IEdmEntityType>().SingleOrDefault(s => s.Name == "VIP"); // Act ODataPath path = _parser.Parse(_model, odataPath); ODataPathSegment segment = path.Segments.Last(); // Assert Assert.NotNull(segment); Assert.Equal(expectedText, segment.ToString()); Assert.Same(expectedSet, path.EntitySet); Assert.Equal(expectedType, path.EdmType); }
public void CanParseEntitySetUrl() { // Arrange string odataPath = "RoutingCustomers"; string expectedText = "RoutingCustomers"; IEdmEntitySet expectedSet = _model.EntityContainers().First().EntitySets().SingleOrDefault(s => s.Name == "RoutingCustomers"); // Act ODataPath path = _parser.Parse(_model, odataPath); ODataPathSegment segment = path.Segments.Last(); // Assert Assert.NotNull(path); Assert.NotNull(segment); Assert.Equal(expectedText, segment.ToString()); Assert.Same(expectedSet, path.EntitySet); Assert.Same(expectedSet.ElementType, (path.EdmType as IEdmCollectionType).ElementType.Definition); }
public void CanParsePropertySegment() { // Arrange string odataPath = "RoutingCustomers(112)/Name"; string expectedText = "Name"; IEdmProperty expectedEdmElement = _model.SchemaElements.OfType <IEdmEntityType>().SingleOrDefault(e => e.Name == "RoutingCustomer").Properties().SingleOrDefault(p => p.Name == "Name"); IEdmType expectedType = expectedEdmElement.Type.Definition; // Act ODataPath path = _parser.Parse(_model, odataPath); ODataPathSegment segment = path.Segments.Last(); // Assert Assert.NotNull(segment); Assert.Equal(expectedText, segment.ToString()); Assert.Null(path.EntitySet); PropertyAccessPathSegment propertyAccess = Assert.IsType <PropertyAccessPathSegment>(segment); Assert.Same(expectedEdmElement, propertyAccess.Property); }
public void CanParseRootProcedureSegment() { // Arrange string odataPath = "GetRoutingCustomerById()"; string expectedText = "Default.Container.GetRoutingCustomerById"; IEdmEntitySet expectedSet = _model.EntityContainers().First().EntitySets().SingleOrDefault(s => s.Name == "RoutingCustomers"); IEdmFunctionImport expectedEdmElement = _model.EntityContainers().First().FunctionImports().SingleOrDefault(s => s.Name == "GetRoutingCustomerById"); // Act ODataPath path = _parser.Parse(_model, odataPath); ODataPathSegment segment = path.Segments.Last(); // Assert Assert.NotNull(segment); Assert.Equal(expectedText, segment.ToString()); Assert.Same(expectedSet, path.EntitySet); Assert.Equal(expectedSet.ElementType, path.EdmType); ActionPathSegment action = Assert.IsType <ActionPathSegment>(segment); Assert.Same(expectedEdmElement, action.Action); }
public void CanParseNavigateToSingleSegment() { // Arrange string odataPath = "RoutingCustomers(100)/System.Web.Http.OData.Routing.VIP/RelationshipManager"; string expectedText = "RelationshipManager"; IEdmEntitySet expectedSet = _model.EntityContainers().First().EntitySets().SingleOrDefault(s => s.Name == "SalesPeople"); IEdmNavigationProperty expectedEdmElement = _model.SchemaElements.OfType <IEdmEntityType>().SingleOrDefault(s => s.Name == "VIP").NavigationProperties().SingleOrDefault(n => n.Name == "RelationshipManager"); // Act ODataPath path = _parser.Parse(_model, odataPath); ODataPathSegment segment = path.Segments.Last(); // Assert Assert.NotNull(segment); Assert.Equal(expectedText, segment.ToString()); Assert.Same(expectedSet, path.EntitySet); Assert.Equal(expectedSet.ElementType, path.EdmType); NavigationPathSegment navigation = Assert.IsType <NavigationPathSegment>(segment); Assert.Same(expectedEdmElement, navigation.NavigationProperty); }
public void CanParseNavigateToCollectionSegment() { // Arrange string odataPath = "RoutingCustomers(100)/Products"; string expectedText = "Products"; IEdmEntitySet expectedSet = _model.EntityContainers().First().EntitySets().SingleOrDefault(s => s.Name == "Products"); IEdmNavigationProperty expectedEdmElement = _model.SchemaElements.OfType <IEdmEntityType>().SingleOrDefault(s => s.Name == "RoutingCustomer").NavigationProperties().SingleOrDefault(n => n.Name == "Products"); // Act ODataPath path = _parser.Parse(_model, odataPath); ODataPathSegment segment = path.Segments.Last(); // Assert Assert.NotNull(segment); Assert.Equal(expectedText, segment.ToString()); Assert.Same(expectedSet, path.EntitySet); Assert.Equal(expectedSet.ElementType, (path.EdmType as IEdmCollectionType).ElementType.Definition); NavigationPathSegment navigation = Assert.IsType <NavigationPathSegment>(segment); Assert.Same(expectedEdmElement, navigation.NavigationProperty); }
public void CanParseKeyUrl() { // Arrange string testUrl = "http://myservice/Customers(112)"; string expectedText = "112"; IEdmEntitySet expectedSet = _parser.Model.EntityContainers().First().EntitySets().SingleOrDefault(s => s.Name == "Customers"); Uri uri = new Uri(testUrl); Uri baseUri = new Uri("http://myservice/"); // Act ODataPath path = _parser.Parse(uri, baseUri); ODataPathSegment segment = path.Segments.Last.Value; // Assert Assert.NotNull(segment); Assert.NotNull(segment.Previous); Assert.Equal(expectedText, segment.ToString()); Assert.IsType <KeyValuePathSegment>(segment); Assert.Same(expectedSet, segment.EntitySet); Assert.Same(expectedSet.ElementType, segment.EdmType); }
public void CanParseCastEntitySegment() { // Arrange string testUrl = "http://myservice/Customers(100)/System.Web.Http.OData.Routing.VIP"; string expectedText = "System.Web.Http.OData.Routing.VIP"; IEdmEntitySet expectedSet = _parser.Model.EntityContainers().First().EntitySets().SingleOrDefault(s => s.Name == "Customers"); IEdmEntityType expectedType = _parser.Model.SchemaElements.OfType <IEdmEntityType>().SingleOrDefault(s => s.Name == "VIP"); Uri uri = new Uri(testUrl); Uri baseUri = new Uri("http://myservice/"); // Act ODataPath path = _parser.Parse(uri, baseUri); ODataPathSegment segment = path.Segments.Last.Value; // Assert Assert.NotNull(segment); Assert.NotNull(segment.Previous); Assert.Equal(expectedText, segment.ToString()); Assert.Same(expectedSet, segment.EntitySet); Assert.Equal(expectedType, segment.EdmType); }
public void CanParseActionBoundToCollectionSegment() { // Arrange string odataPath = "RoutingCustomers/System.Web.Http.OData.Routing.VIP/GetMostProfitable"; string expectedText = "Default.Container.GetMostProfitable"; IEdmFunctionImport expectedEdmElement = _model.EntityContainers().First().FunctionImports().SingleOrDefault(p => p.Name == "GetMostProfitable"); IEdmEntitySet expectedSet = _model.EntityContainers().First().EntitySets().SingleOrDefault(e => e.Name == "RoutingCustomers"); IEdmType expectedType = expectedEdmElement.ReturnType.Definition; // Act ODataPath path = _parser.Parse(_model, odataPath); ODataPathSegment segment = path.Segments.Last(); // Assert Assert.NotNull(segment); Assert.Equal(expectedText, segment.ToString()); Assert.Same(expectedSet, path.EntitySet); Assert.Same(expectedType, path.EdmType); ActionPathSegment action = Assert.IsType <ActionPathSegment>(segment); Assert.Same(expectedEdmElement, action.Action); }
public void CanParsePropertySegment() { // Arrange string testUrl = "http://myservice/Customers(112)/Name"; string expectedText = "Name"; IEdmProperty expectedEdmElement = _parser.Model.SchemaElements.OfType <IEdmEntityType>().SingleOrDefault(e => e.Name == "Customer").Properties().SingleOrDefault(p => p.Name == "Name"); IEdmType expectedType = expectedEdmElement.Type.Definition; Uri uri = new Uri(testUrl); Uri baseUri = new Uri("http://myservice/"); // Act ODataPath path = _parser.Parse(uri, baseUri); ODataPathSegment segment = path.Segments.Last.Value; // Assert Assert.NotNull(segment); Assert.NotNull(segment.Previous); Assert.Equal(expectedText, segment.ToString()); Assert.Null(segment.EntitySet); PropertyAccessPathSegment propertyAccess = Assert.IsType <PropertyAccessPathSegment>(segment); Assert.Same(expectedEdmElement, propertyAccess.Property); }
public void CanParseNavigateToSingleSegment() { // Arrange string testUrl = "http://myservice/Customers(100)/System.Web.Http.OData.Routing.VIP/RelationshipManager"; string expectedText = "RelationshipManager"; IEdmEntitySet expectedSet = _parser.Model.EntityContainers().First().EntitySets().SingleOrDefault(s => s.Name == "SalesPeople"); IEdmNavigationProperty expectedEdmElement = _parser.Model.SchemaElements.OfType <IEdmEntityType>().SingleOrDefault(s => s.Name == "VIP").NavigationProperties().SingleOrDefault(n => n.Name == "RelationshipManager"); Uri uri = new Uri(testUrl); Uri baseUri = new Uri("http://myservice/"); // Act ODataPath path = _parser.Parse(uri, baseUri); ODataPathSegment segment = path.Segments.Last.Value; // Assert Assert.NotNull(segment); Assert.NotNull(segment.Previous); Assert.Equal(expectedText, segment.ToString()); Assert.Same(expectedSet, segment.EntitySet); Assert.Equal(expectedSet.ElementType, segment.EdmType); NavigationPathSegment navigation = Assert.IsType <NavigationPathSegment>(segment); Assert.Same(expectedEdmElement, navigation.NavigationProperty); }
public void CanParseRootProcedureSegment() { // Arrange string testUrl = "http://myservice/GetCustomerById()"; string expectedText = "Default.Container.GetCustomerById"; IEdmEntitySet expectedSet = _parser.Model.EntityContainers().First().EntitySets().SingleOrDefault(s => s.Name == "Customers"); IEdmFunctionImport expectedEdmElement = _parser.Model.EntityContainers().First().FunctionImports().SingleOrDefault(s => s.Name == "GetCustomerById"); Uri uri = new Uri(testUrl); Uri baseUri = new Uri("http://myservice/"); // Act ODataPath path = _parser.Parse(uri, baseUri); ODataPathSegment segment = path.Segments.Last.Value; // Assert Assert.NotNull(segment); Assert.NotNull(segment.Previous); Assert.Equal(expectedText, segment.ToString()); Assert.Same(expectedSet, segment.EntitySet); Assert.Equal(expectedSet.ElementType, segment.EdmType); ActionPathSegment action = Assert.IsType <ActionPathSegment>(segment); Assert.Same(expectedEdmElement, action.Action); }
public void CanParseNavigateToCollectionSegment() { // Arrange string testUrl = "http://myservice/Customers(100)/Products"; string expectedText = "Products"; IEdmEntitySet expectedSet = _parser.Model.EntityContainers().First().EntitySets().SingleOrDefault(s => s.Name == "Products"); IEdmNavigationProperty expectedEdmElement = _parser.Model.SchemaElements.OfType <IEdmEntityType>().SingleOrDefault(s => s.Name == "Customer").NavigationProperties().SingleOrDefault(n => n.Name == "Products"); Uri uri = new Uri(testUrl); Uri baseUri = new Uri("http://myservice/"); // Act ODataPath path = _parser.Parse(uri, baseUri); ODataPathSegment segment = path.Segments.Last.Value; // Assert Assert.NotNull(segment); Assert.NotNull(segment.Previous); Assert.Equal(expectedText, segment.ToString()); Assert.Same(expectedSet, segment.EntitySet); Assert.Equal(expectedSet.ElementType, (segment.EdmType as IEdmCollectionType).ElementType.Definition); NavigationPathSegment navigation = Assert.IsType <NavigationPathSegment>(segment); Assert.Same(expectedEdmElement, navigation.NavigationProperty); }