1
+ using NUnit . Framework ;
2
+
3
+ namespace ServiceStack . Text . Tests
4
+ {
5
+ [ TestFixture ]
6
+ public class HttpUtilsTests
7
+ {
8
+ [ Test ]
9
+ public void Can_AddQueryParam ( )
10
+ {
11
+ Assert . That ( "http://example.com" . AddQueryParam ( "f" , "1" ) , Is . EqualTo ( "http://example.com?f=1" ) ) ;
12
+ Assert . That ( "http://example.com?s=0" . AddQueryParam ( "f" , "1" ) , Is . EqualTo ( "http://example.com?s=0&f=1" ) ) ;
13
+ Assert . That ( "http://example.com?f=1" . AddQueryParam ( "f" , "2" ) , Is . EqualTo ( "http://example.com?f=1&f=2" ) ) ;
14
+ Assert . That ( "http://example.com?s=0&f=1&s=1" . AddQueryParam ( "f" , "2" ) , Is . EqualTo ( "http://example.com?s=0&f=1&s=1&f=2" ) ) ;
15
+ }
16
+
17
+ [ Test ]
18
+ public void Can_SetQueryParam ( )
19
+ {
20
+ Assert . That ( "http://example.com" . SetQueryParam ( "f" , "1" ) , Is . EqualTo ( "http://example.com?f=1" ) ) ;
21
+ Assert . That ( "http://example.com?s=0" . SetQueryParam ( "f" , "1" ) , Is . EqualTo ( "http://example.com?s=0&f=1" ) ) ;
22
+ Assert . That ( "http://example.com?f=1" . SetQueryParam ( "f" , "2" ) , Is . EqualTo ( "http://example.com?f=2" ) ) ;
23
+ Assert . That ( "http://example.com?s=0&f=1&s=1" . SetQueryParam ( "f" , "2" ) , Is . EqualTo ( "http://example.com?s=0&f=2&s=1" ) ) ;
24
+ }
25
+
26
+ [ Test ]
27
+ public void Can_AddHashParam ( )
28
+ {
29
+ Assert . That ( "http://example.com" . AddHashParam ( "f" , "1" ) , Is . EqualTo ( "http://example.com#f=1" ) ) ;
30
+ Assert . That ( "http://example.com#s=0" . AddHashParam ( "f" , "1" ) , Is . EqualTo ( "http://example.com#s=0/f=1" ) ) ;
31
+ Assert . That ( "http://example.com#f=1" . AddHashParam ( "f" , "2" ) , Is . EqualTo ( "http://example.com#f=1/f=2" ) ) ;
32
+ Assert . That ( "http://example.com#s=0/f=1/s=1" . AddHashParam ( "f" , "2" ) , Is . EqualTo ( "http://example.com#s=0/f=1/s=1/f=2" ) ) ;
33
+ }
34
+
35
+ [ Test ]
36
+ public void Can_SetHashParam ( )
37
+ {
38
+ Assert . That ( "http://example.com" . SetHashParam ( "f" , "1" ) , Is . EqualTo ( "http://example.com#f=1" ) ) ;
39
+ Assert . That ( "http://example.com#s=0" . SetHashParam ( "f" , "1" ) , Is . EqualTo ( "http://example.com#s=0/f=1" ) ) ;
40
+ Assert . That ( "http://example.com#f=1" . SetHashParam ( "f" , "2" ) , Is . EqualTo ( "http://example.com#f=2" ) ) ;
41
+ Assert . That ( "http://example.com#s=0/f=1/s=1" . SetHashParam ( "f" , "2" ) , Is . EqualTo ( "http://example.com#s=0/f=2/s=1" ) ) ;
42
+ }
43
+ }
44
+ }
0 commit comments