public void AccessingEntity_NonExistingProperty() { var model = new StubModel( m => m.EntitySet("catalogs", new List <Catalog1>().AsQueryable()) ); SegmentParser.parse("/catalogs(1)/Something", String.Empty, model); }
public void Process(string fullPath, SegmentOp operation, ODataModel model, string contentType = "application/atom+xml", string accept = "application/atom+xml", Stream inputStream = null) { _body = new StringBuilder(); var segments = SegmentParser.parse(fullPath, String.Empty, model); _response = new ResponseParameters(null, Encoding.UTF8, new StringWriter(_body), 200); var callbacks = new ProcessorCallbacks( (rt, item) => { _accessSingle.Add(new Tuple <ResourceType, object>(rt, item)); return(true); }, (rt, items) => { _accessMany.Add(new Tuple <ResourceType, IEnumerable>(rt, items)); return(true); }, (rt, item) => { _created.Add(new Tuple <ResourceType, object>(rt, item)); return(true); }, (rt, item) => { _updated.Add(new Tuple <ResourceType, object>(rt, item)); return(true); }, (rt, item) => { _removed.Add(new Tuple <ResourceType, object>(rt, item)); return(true); } ); SegmentProcessor.Process(operation, segments, callbacks, new RequestParameters( model, model as IDataServiceMetadataProvider, new DataServiceMetadataProviderWrapper(model), contentType, Encoding.UTF8, inputStream, new Uri("http://localhost/base/"), new [] { accept } ), _response ); }
public void AccessingEntityByKey_2() { var model = new StubModel( m => m.EntitySet("catalogs", new List <Catalog1>().AsQueryable()) ); var segments = SegmentParser.parse("/catalogs(10)", String.Empty, model); Asserts.ExpectingSegmentsCount(segments, 1); Asserts.IsEntityType(segments.ElementAt(0), Key: "10", Name: "catalogs", resource: model.GetResourceType("catalogs").Value); }
public void AccessingEntityAndPropValue_2() { var model = new StubModel( m => m.EntitySet("catalogs", new List <Catalog1>().AsQueryable()) ); var segments = SegmentParser.parse("/catalogs(1)/Name/$value", String.Empty, model); Asserts.ExpectingSegmentsCount(segments, 3); Asserts.IsEntityType(segments.ElementAt(0), Key: "1", Name: "catalogs", resource: model.GetResourceType("catalogs").Value); Asserts.IsPropertySingle(segments.ElementAt(1), "Name"); Asserts.IsMeta_Value(segments.ElementAt(2)); }
public void AccessingEntity_And_OneToManyRelationshipWithKey_() { var model = new StubModel( m => { m.EntitySet("catalogs", new List <Catalog2>().AsQueryable()); m.EntitySet("products", new List <Product2>().AsQueryable()); }); var segments = SegmentParser.parse("/catalogs(1)/Products(2)/", String.Empty, model); Asserts.ExpectingSegmentsCount(segments, 2); Asserts.IsEntityType(segments.ElementAt(0), Key: "1", Name: "catalogs", resource: model.GetResourceType("catalogs").Value); Asserts.IsPropertySingle(segments.ElementAt(1), name: "Products", key: "2"); }
public void AccessingEntity_And_OneToManyRelationship_1() { var model = new StubModel( m => { m.EntitySet("catalogs", new List <Catalog2>().AsQueryable()); m.EntitySet("products", new List <Product2>().AsQueryable()); }); var segments = SegmentParser.parse("/catalogs(1)/Products/", String.Empty, model); Asserts.ExpectingSegmentsCount(segments, 2); Asserts.IsEntityType(segments.ElementAt(0), Key: "1", Name: "catalogs", resource: model.GetResourceType("catalogs").Value); // Not sure which one this should be? Products or catalog? Asserts.IsPropertyCollection(segments.ElementAt(1), Name: "Products", resource: model.GetResourceType("products").Value); }
public void AccessingEntity_ThatDoesNotExists_HttpError() { SegmentParser.parse("/catalogs", String.Empty, new StubModel(null)); }
public void MetadataIdentifier_2() { var segments = SegmentParser.parse("/$metadata", String.Empty, new StubModel(null)); Asserts.FirstSegmentIsMetadata(segments); }
public void ServiceDirectory_2() { var segments = SegmentParser.parse(string.Empty, string.Empty, new StubModel(null)); Asserts.FirstSegmentIsServiceDirectory(segments); }