@@ -54,7 +54,7 @@ public void CreateOperationForEdmActionReturnsCorrectOperation()
5454 }
5555
5656 [ Fact ]
57- public void CreateOperationForEdmActionReturnsCorrectOperationHierarhicalClass ( )
57+ public void CreateOperationForEdmActionReturnsCorrectOperationHierarchicalClass ( )
5858 {
5959 // Arrange
6060 IEdmModel model = EdmModelHelper . ContractServiceModel ;
@@ -296,5 +296,44 @@ public void OperationRestrictionsTermWorksToCreateOperationForEdmAction(bool ena
296296 Assert . Empty ( operation . Security ) ;
297297 }
298298 }
299+
300+ [ Theory ]
301+ [ InlineData ( "getMailTips" , true ) ] // returns collection
302+ [ InlineData ( "getMailTips" , false ) ] // returns collection
303+ [ InlineData ( "findMeetingTimes" , true ) ] // does not return collection
304+ public void CreateOperationForEdmActionWithCollectionReturnTypeContainsXMsPageableExtension ( string actionName , bool enablePagination )
305+ {
306+ // Arrange
307+ IEdmModel model = EdmModelHelper . GraphBetaModel ;
308+ OpenApiConvertSettings settings = new OpenApiConvertSettings
309+ {
310+ EnableOperationId = true ,
311+ EnablePagination = enablePagination
312+ } ;
313+ ODataContext context = new ODataContext ( model , settings ) ;
314+ IEdmAction action = model . SchemaElements . OfType < IEdmAction > ( )
315+ . First ( x => x . Name == actionName &&
316+ x . FindParameter ( "bindingParameter" ) . Type . Definition . ToString ( ) == "microsoft.graph.user" ) ;
317+ IEdmEntityContainer container = model . SchemaElements . OfType < IEdmEntityContainer > ( ) . First ( ) ;
318+ IEdmEntitySet users = container . FindEntitySet ( "users" ) ;
319+ IEdmEntityType user = model . SchemaElements . OfType < IEdmEntityType > ( ) . First ( x => x . Name == "user" ) ;
320+
321+ ODataPath path = new ODataPath ( new ODataNavigationSourceSegment ( users ) ,
322+ new ODataKeySegment ( user ) ,
323+ new ODataOperationSegment ( action ) ) ;
324+
325+ // Act
326+ var operation = _operationHandler . CreateOperation ( context , path ) ;
327+
328+ // Assert
329+ if ( enablePagination && action . ReturnType . IsCollection ( ) )
330+ {
331+ Assert . True ( operation . Extensions . ContainsKey ( Common . Constants . xMsPageable ) ) ;
332+ }
333+ else
334+ {
335+ Assert . False ( operation . Extensions . ContainsKey ( Common . Constants . xMsPageable ) ) ;
336+ }
337+ }
299338 }
300339}
0 commit comments