@@ -40,7 +40,7 @@ public class OpenApiReferencableTests
40
40
private static readonly OpenApiSecurityScheme _securitySchemeFragment = new OpenApiSecurityScheme ( ) ;
41
41
private static readonly OpenApiTag _tagFragment = new OpenApiTag ( ) ;
42
42
43
- public static IEnumerable < object [ ] > ReferencableElementsCanResolveReferencesTestData =>
43
+ public static IEnumerable < object [ ] > ResolveReferenceCanResolveValidJsonPointersTestData =>
44
44
new List < object [ ] >
45
45
{
46
46
new object [ ] { _callbackFragment , "/" , _callbackFragment } ,
@@ -60,36 +60,46 @@ public class OpenApiReferencableTests
60
60
} ;
61
61
62
62
[ Theory ]
63
- [ MemberData ( nameof ( ReferencableElementsCanResolveReferencesTestData ) ) ]
64
- public void ReferencableElementsCanResolveReferences (
63
+ [ MemberData ( nameof ( ResolveReferenceCanResolveValidJsonPointersTestData ) ) ]
64
+ public void ResolveReferenceCanResolveValidJsonPointers (
65
65
IOpenApiReferenceable element ,
66
- string pointer ,
66
+ string jsonPointer ,
67
67
IOpenApiElement expectedResolvedElement )
68
68
{
69
69
// Act
70
- var actualResolvedElement = element . ResolveReference ( pointer ) ;
70
+ var actualResolvedElement = element . ResolveReference ( jsonPointer ) ;
71
71
72
72
// Assert
73
73
Assert . Same ( expectedResolvedElement , actualResolvedElement ) ;
74
74
}
75
75
76
- public static IEnumerable < object [ ] > ParameterElementShouldThrowOnInvalidReferenceIdTestData =>
76
+ public static IEnumerable < object [ ] > ResolveReferenceShouldThrowOnInvalidReferenceIdTestData =>
77
77
new List < object [ ] >
78
78
{
79
- new object [ ] { "" } ,
80
- new object [ ] { "a" } ,
81
- new object [ ] { "examples" } ,
82
- new object [ ] { "examples/" } ,
83
- new object [ ] { "examples/a" } ,
79
+ new object [ ] { _callbackFragment , null } ,
80
+ new object [ ] { _callbackFragment , "" } ,
81
+ new object [ ] { _callbackFragment , "/a" } ,
82
+ new object [ ] { _headerFragment , null } ,
83
+ new object [ ] { _headerFragment , "" } ,
84
+ new object [ ] { _headerFragment , "/a" } ,
85
+ new object [ ] { _headerFragment , "/examples" } ,
86
+ new object [ ] { _headerFragment , "/examples/" } ,
87
+ new object [ ] { _headerFragment , "/examples/a" } ,
88
+ new object [ ] { _parameterFragment , null } ,
89
+ new object [ ] { _parameterFragment , "" } ,
90
+ new object [ ] { _parameterFragment , "/a" } ,
91
+ new object [ ] { _parameterFragment , "/examples" } ,
92
+ new object [ ] { _parameterFragment , "/examples/" } ,
93
+ new object [ ] { _parameterFragment , "/examples/a" }
84
94
85
95
} ;
86
96
87
97
[ Theory ]
88
- [ MemberData ( nameof ( ParameterElementShouldThrowOnInvalidReferenceIdTestData ) ) ]
89
- public void ParameterElementShouldThrowOnInvalidReferenceId ( string jsonPointer )
98
+ [ MemberData ( nameof ( ResolveReferenceShouldThrowOnInvalidReferenceIdTestData ) ) ]
99
+ public void ResolveReferenceShouldThrowOnInvalidReferenceId ( IOpenApiReferenceable element , string jsonPointer )
90
100
{
91
101
// Act
92
- Action resolveReference = ( ) => _parameterFragment . ResolveReference ( jsonPointer ) ;
102
+ Action resolveReference = ( ) => element . ResolveReference ( jsonPointer ) ;
93
103
94
104
// Assert
95
105
var exception = Assert . Throws < OpenApiException > ( resolveReference ) ;
0 commit comments