66
77namespace ServiceStack . Redis . Tests
88{
9- [ TestFixture , Category ( "Integration" ) ]
10- public class AdhocClientTests
11- {
12- [ Test ]
13- public void Search_Test ( )
14- {
15- using ( var client = new RedisClient ( TestConfig . SingleHost ) )
16- {
17- const string cacheKey = "urn+metadata:All:SearchProProfiles?SwanShinichi Osawa /0/8,0,0,0" ;
18- const long value = 1L ;
19- client . Set ( cacheKey , value ) ;
20- var result = client . Get < long > ( cacheKey ) ;
21-
22- Assert . That ( result , Is . EqualTo ( value ) ) ;
23- }
24- }
9+ [ TestFixture , Category ( "Integration" ) ]
10+ public class AdhocClientTests
11+ {
12+ [ Test ]
13+ public void Search_Test ( )
14+ {
15+ using ( var client = new RedisClient ( TestConfig . SingleHost ) )
16+ {
17+ const string cacheKey = "urn+metadata:All:SearchProProfiles?SwanShinichi Osawa /0/8,0,0,0" ;
18+ const long value = 1L ;
19+ client . Set ( cacheKey , value ) ;
20+ var result = client . Get < long > ( cacheKey ) ;
21+
22+ Assert . That ( result , Is . EqualTo ( value ) ) ;
23+ }
24+ }
2525
2626 public string CalculateMD5Hash ( string input )
2727 {
2828 // step 1, calculate MD5 hash from input
2929 var md5 = MD5 . Create ( ) ;
3030 byte [ ] inputBytes = Encoding . ASCII . GetBytes ( input ) ;
3131 byte [ ] hash = md5 . ComputeHash ( inputBytes ) ;
32-
32+
3333 // step 2, convert byte array to hex string
3434 var sb = new StringBuilder ( ) ;
3535 for ( int i = 0 ; i < hash . Length ; i ++ )
@@ -39,69 +39,69 @@ public string CalculateMD5Hash(string input)
3939 return sb . ToString ( ) ;
4040 }
4141
42- [ Test ]
43- public void Can_infer_utf8_bytes ( )
44- {
45- var cmd = "GET" + 2 + "\r \n " ;
46- var cmdBytes = System . Text . Encoding . UTF8 . GetBytes ( cmd ) ;
42+ [ Test ]
43+ public void Can_infer_utf8_bytes ( )
44+ {
45+ var cmd = "GET" + 2 + "\r \n " ;
46+ var cmdBytes = System . Text . Encoding . UTF8 . GetBytes ( cmd ) ;
4747
48- var hex = BitConverter . ToString ( cmdBytes ) ;
48+ var hex = BitConverter . ToString ( cmdBytes ) ;
4949
50- Debug . WriteLine ( hex ) ;
50+ Debug . WriteLine ( hex ) ;
5151
52- Debug . WriteLine ( BitConverter . ToString ( "G" . ToUtf8Bytes ( ) ) ) ;
53- Debug . WriteLine ( BitConverter . ToString ( "E" . ToUtf8Bytes ( ) ) ) ;
54- Debug . WriteLine ( BitConverter . ToString ( "T" . ToUtf8Bytes ( ) ) ) ;
55- Debug . WriteLine ( BitConverter . ToString ( "2" . ToUtf8Bytes ( ) ) ) ;
56- Debug . WriteLine ( BitConverter . ToString ( "\r " . ToUtf8Bytes ( ) ) ) ;
57- Debug . WriteLine ( BitConverter . ToString ( "\n " . ToUtf8Bytes ( ) ) ) ;
52+ Debug . WriteLine ( BitConverter . ToString ( "G" . ToUtf8Bytes ( ) ) ) ;
53+ Debug . WriteLine ( BitConverter . ToString ( "E" . ToUtf8Bytes ( ) ) ) ;
54+ Debug . WriteLine ( BitConverter . ToString ( "T" . ToUtf8Bytes ( ) ) ) ;
55+ Debug . WriteLine ( BitConverter . ToString ( "2" . ToUtf8Bytes ( ) ) ) ;
56+ Debug . WriteLine ( BitConverter . ToString ( "\r " . ToUtf8Bytes ( ) ) ) ;
57+ Debug . WriteLine ( BitConverter . ToString ( "\n " . ToUtf8Bytes ( ) ) ) ;
5858
59- var bytes = new [ ] { ( byte ) '\r ' , ( byte ) '\n ' , ( byte ) '0' , ( byte ) '9' , } ;
60- Debug . WriteLine ( BitConverter . ToString ( bytes ) ) ;
61- }
59+ var bytes = new [ ] { ( byte ) '\r ' , ( byte ) '\n ' , ( byte ) '0' , ( byte ) '9' , } ;
60+ Debug . WriteLine ( BitConverter . ToString ( bytes ) ) ;
61+ }
6262
63- [ Test ]
64- public void Convert_int ( )
65- {
66- var test = 1234 ;
67- Debug . WriteLine ( BitConverter . ToString ( 1234 . ToString ( ) . ToUtf8Bytes ( ) ) ) ;
68- }
63+ [ Test ]
64+ public void Convert_int ( )
65+ {
66+ var test = 1234 ;
67+ Debug . WriteLine ( BitConverter . ToString ( 1234 . ToString ( ) . ToUtf8Bytes ( ) ) ) ;
68+ }
6969
70- private static byte [ ] GetCmdBytes1 ( char cmdPrefix , int noOfLines )
71- {
72- var cmd = cmdPrefix . ToString ( ) + noOfLines . ToString ( ) + "\r \n " ;
73- return cmd . ToUtf8Bytes ( ) ;
74- }
70+ private static byte [ ] GetCmdBytes1 ( char cmdPrefix , int noOfLines )
71+ {
72+ var cmd = cmdPrefix . ToString ( ) + noOfLines . ToString ( ) + "\r \n " ;
73+ return cmd . ToUtf8Bytes ( ) ;
74+ }
7575
76- private static byte [ ] GetCmdBytes2 ( char cmdPrefix , int noOfLines )
77- {
78- var strLines = noOfLines . ToString ( ) ;
79- var cmdBytes = new byte [ 1 + strLines . Length + 2 ] ;
80- cmdBytes [ 0 ] = ( byte ) cmdPrefix ;
76+ private static byte [ ] GetCmdBytes2 ( char cmdPrefix , int noOfLines )
77+ {
78+ var strLines = noOfLines . ToString ( ) ;
79+ var cmdBytes = new byte [ 1 + strLines . Length + 2 ] ;
80+ cmdBytes [ 0 ] = ( byte ) cmdPrefix ;
8181
82- for ( var i = 0 ; i < strLines . Length ; i ++ )
83- cmdBytes [ i + 1 ] = ( byte ) strLines [ i ] ;
82+ for ( var i = 0 ; i < strLines . Length ; i ++ )
83+ cmdBytes [ i + 1 ] = ( byte ) strLines [ i ] ;
8484
85- cmdBytes [ cmdBytes . Length - 2 ] = 0x0D ; // \r
86- cmdBytes [ cmdBytes . Length - 1 ] = 0x0A ; // \n
85+ cmdBytes [ cmdBytes . Length - 2 ] = 0x0D ; // \r
86+ cmdBytes [ cmdBytes . Length - 1 ] = 0x0A ; // \n
8787
88- return cmdBytes ;
89- }
88+ return cmdBytes ;
89+ }
9090
91- [ Test ]
92- public void Compare_GetCmdBytes ( )
93- {
94- var res1 = GetCmdBytes1 ( '$' , 1234 ) ;
95- var res2 = GetCmdBytes2 ( '$' , 1234 ) ;
91+ [ Test ]
92+ public void Compare_GetCmdBytes ( )
93+ {
94+ var res1 = GetCmdBytes1 ( '$' , 1234 ) ;
95+ var res2 = GetCmdBytes2 ( '$' , 1234 ) ;
9696
97- Debug . WriteLine ( BitConverter . ToString ( res1 ) ) ;
98- Debug . WriteLine ( BitConverter . ToString ( res2 ) ) ;
97+ Debug . WriteLine ( BitConverter . ToString ( res1 ) ) ;
98+ Debug . WriteLine ( BitConverter . ToString ( res2 ) ) ;
9999
100- var ticks1 = PerfUtils . Measure ( ( ) => GetCmdBytes1 ( '$' , 2 ) ) ;
101- var ticks2 = PerfUtils . Measure ( ( ) => GetCmdBytes2 ( '$' , 2 ) ) ;
100+ var ticks1 = PerfUtils . Measure ( ( ) => GetCmdBytes1 ( '$' , 2 ) ) ;
101+ var ticks2 = PerfUtils . Measure ( ( ) => GetCmdBytes2 ( '$' , 2 ) ) ;
102102
103- Debug . WriteLine ( String . Format ( "{0} : {1} = {2}" , ticks1 , ticks2 , ticks1 / ( double ) ticks2 ) ) ;
104- }
103+ Debug . WriteLine ( String . Format ( "{0} : {1} = {2}" , ticks1 , ticks2 , ticks1 / ( double ) ticks2 ) ) ;
104+ }
105105
106- }
106+ }
107107}
0 commit comments