@@ -16,7 +16,58 @@ namespace Microsoft.OpenApi.OData.Operation.Tests
16
16
{
17
17
public class EdmFunctionOperationHandlerTests
18
18
{
19
- private EdmFunctionOperationHandler _operationHandler = new EdmFunctionOperationHandler ( ) ;
19
+ private EdmFunctionOperationHandler _operationHandler = new ( ) ;
20
+ #region OperationHandlerTests
21
+ [ Fact ]
22
+ public void SetsDeprecationInformation ( )
23
+ {
24
+ // Arrange
25
+ IEdmModel model = EdmModelHelper . TripServiceModel ;
26
+ ODataContext context = new ( model ) ;
27
+ IEdmEntitySet people = model . EntityContainer . FindEntitySet ( "People" ) ;
28
+ Assert . NotNull ( people ) ;
29
+
30
+ IEdmFunction function = model . SchemaElements . OfType < IEdmFunction > ( ) . First ( f => f . Name == "GetFriendsTrips" ) ;
31
+ Assert . NotNull ( function ) ;
32
+
33
+ ODataPath path = new ( new ODataNavigationSourceSegment ( people ) , new ODataKeySegment ( people . EntityType ( ) ) , new ODataOperationSegment ( function ) ) ;
34
+
35
+ // Act
36
+ var operation = _operationHandler . CreateOperation ( context , path ) ;
37
+
38
+ // Assert
39
+ Assert . NotNull ( operation ) ;
40
+ Assert . True ( operation . Deprecated ) ;
41
+ Assert . NotEmpty ( operation . Extensions ) ;
42
+ var extension = operation . Extensions [ "x-ms-deprecation" ] ;
43
+ Assert . NotNull ( extension ) ;
44
+ }
45
+ [ Fact ]
46
+ public void DoesntSetDeprecationInformation ( )
47
+ {
48
+ // Arrange
49
+ IEdmModel model = EdmModelHelper . TripServiceModel ;
50
+ ODataContext context = new ( model ) ;
51
+ IEdmEntitySet people = model . EntityContainer . FindEntitySet ( "People" ) ;
52
+ Assert . NotNull ( people ) ;
53
+
54
+ IEdmFunction function = model . SchemaElements . OfType < IEdmFunction > ( ) . First ( f => f . Name == "GetFavoriteAirline" ) ;
55
+ Assert . NotNull ( function ) ;
56
+
57
+ ODataPath path = new ( new ODataNavigationSourceSegment ( people ) , new ODataKeySegment ( people . EntityType ( ) ) , new ODataOperationSegment ( function ) ) ;
58
+
59
+ // Act
60
+ var operation = _operationHandler . CreateOperation ( context , path ) ;
61
+
62
+ // Assert
63
+ Assert . NotNull ( operation ) ;
64
+ Assert . True ( operation . Deprecated ) ;
65
+ Assert . NotEmpty ( operation . Extensions ) ;
66
+ var extension = operation . Extensions [ "x-ms-deprecation" ] ;
67
+ Assert . NotNull ( extension ) ;
68
+ }
69
+
70
+ #endregion
20
71
21
72
[ Fact ]
22
73
public void CreateOperationForEdmFunctionReturnsCorrectOperation ( )
0 commit comments