1
- namespace RestSharp . Tests ;
1
+ namespace RestSharp . Tests . Parameters ;
2
2
3
- public class ParametersTests {
3
+ public class UrlSegmentTests {
4
4
const string BaseUrl = "http://localhost:8888/" ;
5
5
6
- [ Fact ]
7
- public void AddDefaultHeadersUsingDictionary ( ) {
8
- var headers = new Dictionary < string , string > {
9
- { KnownHeaders . ContentType , ContentType . Json } ,
10
- { KnownHeaders . Accept , ContentType . Json } ,
11
- { KnownHeaders . ContentEncoding , "gzip, deflate" }
12
- } ;
13
-
14
- var expected = headers . Select ( x => new HeaderParameter ( x . Key , x . Value ) ) ;
15
-
16
- using var client = new RestClient ( BaseUrl ) ;
17
- client . AddDefaultHeaders ( headers ) ;
18
-
19
- var actual = client . DefaultParameters . Select ( x => x as HeaderParameter ) ;
20
- expected . Should ( ) . BeSubsetOf ( actual ) ;
21
- }
22
-
23
6
[ Fact ]
24
7
public void AddUrlSegmentWithInt ( ) {
25
8
const string name = "foo" ;
@@ -63,4 +46,28 @@ public void AddUrlSegmentModifiesUrlSegmentWithString() {
63
46
64
47
expected . Should ( ) . BeEquivalentTo ( actual ) ;
65
48
}
49
+
50
+ [ Theory ]
51
+ [ InlineData ( "bar%2fBAR" ) ]
52
+ [ InlineData ( "bar%2FBAR" ) ]
53
+ public void UrlSegmentParameter_WithValueWithEncodedSlash_WillReplaceEncodedSlashByDefault ( string inputValue ) {
54
+ var urlSegmentParameter = new UrlSegmentParameter ( "foo" , inputValue ) ;
55
+ urlSegmentParameter . Value . Should ( ) . BeEquivalentTo ( "bar/BAR" ) ;
56
+ }
57
+
58
+ [ Theory ]
59
+ [ InlineData ( "bar%2fBAR" ) ]
60
+ [ InlineData ( "bar%2FBAR" ) ]
61
+ public void UrlSegmentParameter_WithValueWithEncodedSlash_CanReplaceEncodedSlash ( string inputValue ) {
62
+ var urlSegmentParameter = new UrlSegmentParameter ( "foo" , inputValue , replaceEncodedSlash : true ) ;
63
+ urlSegmentParameter . Value . Should ( ) . BeEquivalentTo ( "bar/BAR" ) ;
64
+ }
65
+
66
+ [ Theory ]
67
+ [ InlineData ( "bar%2fBAR" ) ]
68
+ [ InlineData ( "bar%2FBAR" ) ]
69
+ public void UrlSegmentParameter_WithValueWithEncodedSlash_CanLeaveEncodedSlash ( string inputValue ) {
70
+ var urlSegmentParameter = new UrlSegmentParameter ( "foo" , inputValue , replaceEncodedSlash : false ) ;
71
+ urlSegmentParameter . Value . Should ( ) . BeEquivalentTo ( inputValue ) ;
72
+ }
66
73
}
0 commit comments