@@ -50,14 +50,22 @@ await sender.Table("metrics")
5050 . Symbol ( "tag" , "value" )
5151 . Column ( "number" , 10 )
5252 . Column ( "string" , "abc" )
53- . Column ( "array" , new [ ] { 1.2 , 2.6 , 3.1 } )
53+ . Column ( "array" , new [ ]
54+ {
55+ 1.2 , 2.6 ,
56+ 3.1 ,
57+ } )
5458 . AtAsync ( new DateTime ( 1970 , 01 , 01 , 0 , 0 , 1 ) ) ;
5559
5660 await sender . Table ( "metrics" )
5761 . Symbol ( "tag" , "value" )
5862 . Column ( "number" , 10 )
5963 . Column ( "string" , "abc" )
60- . Column ( "array" , ( ReadOnlySpan < double > ) ( new [ ] { 1.5 , 2.1 , 3.1 } ) )
64+ . Column ( "array" , ( ReadOnlySpan < double > ) new [ ]
65+ {
66+ 1.5 , 2.1 ,
67+ 3.1 ,
68+ } )
6169 . AtAsync ( new DateTime ( 1970 , 01 , 01 , 0 , 0 , 2 ) ) ;
6270
6371 await sender . Table ( "metrics" )
@@ -90,16 +98,17 @@ public async Task SendLongArrayAsSpan()
9098 . Column ( "number" , 10 )
9199 . Column ( "string" , "abc" ) ;
92100
93- int arrayLen = ( 1024 - sender . Length ) / 8 + 1 ;
94- double [ ] aray = new double [ arrayLen ] ;
95- StringBuilder expectedArray = new StringBuilder ( ) ;
96- for ( int i = 0 ; i < arrayLen ; i ++ )
101+ var arrayLen = ( 1024 - sender . Length ) / 8 + 1 ;
102+ var aray = new double [ arrayLen ] ;
103+ var expectedArray = new StringBuilder ( ) ;
104+ for ( var i = 0 ; i < arrayLen ; i ++ )
97105 {
98106 aray [ i ] = 1.5 ;
99107 if ( i > 0 )
100108 {
101109 expectedArray . Append ( "," ) ;
102110 }
111+
103112 expectedArray . Append ( "1.5" ) ;
104113 }
105114
@@ -118,7 +127,10 @@ public async Task BasicArrayDoubleNegotiationVersion2NotSupported()
118127 {
119128 {
120129 using var server = new DummyHttpServer ( withBasicAuth : false ) ;
121- await server . StartAsync ( HttpPort , new [ ] { 1 } ) ;
130+ await server . StartAsync ( HttpPort , new [ ]
131+ {
132+ 1 ,
133+ } ) ;
122134 using var sender =
123135 Sender . New (
124136 $ "http::addr={ Host } :{ HttpPort } ;username=asdasdada;password=asdadad;tls_verify=unsafe_off;auto_flush=off;") ;
@@ -129,14 +141,22 @@ public async Task BasicArrayDoubleNegotiationVersion2NotSupported()
129141 . Column ( "string" , "abc" ) ;
130142
131143 Assert . That (
132- ( ) => sender . Column ( "array" , new [ ] { 1.2 , 2.6 , 3.1 } ) ,
144+ ( ) => sender . Column ( "array" , new [ ]
145+ {
146+ 1.2 , 2.6 ,
147+ 3.1 ,
148+ } ) ,
133149 Throws . TypeOf < IngressError > ( ) . With . Message . Contains ( "does not support ARRAY types" ) ) ;
134150 await server . StopAsync ( ) ;
135151 }
136152
137153 {
138154 using var server = new DummyHttpServer ( withBasicAuth : false ) ;
139- await server . StartAsync ( HttpPort , new [ ] { 3 , 4 , 5 } ) ;
155+ await server . StartAsync ( HttpPort , new [ ]
156+ {
157+ 3 , 4 ,
158+ 5 ,
159+ } ) ;
140160 using var sender =
141161 Sender . New (
142162 $ "http::addr={ Host } :{ HttpPort } ;username=asdasdada;password=asdadad;tls_verify=unsafe_off;auto_flush=off;") ;
@@ -147,7 +167,11 @@ public async Task BasicArrayDoubleNegotiationVersion2NotSupported()
147167 . Column ( "string" , "abc" ) ;
148168
149169 Assert . That (
150- ( ) => sender . Column ( "array" , new [ ] { 1.2 , 2.6 , 3.1 } ) ,
170+ ( ) => sender . Column ( "array" , new [ ]
171+ {
172+ 1.2 , 2.6 ,
173+ 3.1 ,
174+ } ) ,
151175 Throws . TypeOf < IngressError > ( ) . With . Message . Contains ( "does not support ARRAY types" ) ) ;
152176 await server . StopAsync ( ) ;
153177 }
@@ -160,7 +184,10 @@ public async Task ArrayNegotiationConnectionIsRetried()
160184 using var server = new DummyHttpServer ( withBasicAuth : false , withStartDelay : TimeSpan . FromSeconds ( 0.5 ) ) ;
161185
162186 // Do not wait for the server start
163- Task delayedStart = server . StartAsync ( HttpPort , new [ ] { 2 } ) ;
187+ var delayedStart = server . StartAsync ( HttpPort , new [ ]
188+ {
189+ 2 ,
190+ } ) ;
164191
165192 using var sender =
166193 Sender . New (
@@ -172,7 +199,11 @@ await sender.Table("metrics")
172199 . Symbol ( "tag" , "value" )
173200 . Column ( "number" , 10 )
174201 . Column ( "string" , "abc" )
175- . Column ( "array" , new [ ] { 1.2 , 2.6 , 3.1 } )
202+ . Column ( "array" , new [ ]
203+ {
204+ 1.2 , 2.6 ,
205+ 3.1 ,
206+ } )
176207 . AtAsync ( new DateTime ( 1970 , 01 , 01 , 0 , 0 , 1 ) ) ;
177208
178209 await sender . SendAsync ( ) ;
@@ -218,7 +249,14 @@ await sender.Table("metrics")
218249 . Symbol ( "tag" , "value" )
219250 . Column ( "number" , 10 )
220251 . Column ( "string" , "abc" )
221- . Column ( "array" , new [ ] { 1.2 , 2.6 , 3.1 , 4.6 } . AsEnumerable ( ) , new [ ] { 2 , 2 } . AsEnumerable ( ) )
252+ . Column ( "array" , new [ ]
253+ {
254+ 1.2 , 2.6 ,
255+ 3.1 , 4.6 ,
256+ } . AsEnumerable ( ) , new [ ]
257+ {
258+ 2 , 2 ,
259+ } . AsEnumerable ( ) )
222260 . AtAsync ( new DateTime ( 1970 , 01 , 01 , 0 , 0 , 1 ) ) ;
223261
224262 await sender . SendAsync ( ) ;
@@ -241,12 +279,26 @@ public void InvalidShapedEnumerableDouble()
241279 . Column ( "string" , "abc" ) ;
242280
243281 Assert . That (
244- ( ) => sender . Column ( "array" , new [ ] { 1.2 , 2.6 , 3.1 , 4.6 } . AsEnumerable ( ) , new [ ] { 0 , 0 } . AsEnumerable ( ) ) ,
282+ ( ) => sender . Column ( "array" , new [ ]
283+ {
284+ 1.2 , 2.6 ,
285+ 3.1 , 4.6 ,
286+ } . AsEnumerable ( ) , new [ ]
287+ {
288+ 0 , 0 ,
289+ } . AsEnumerable ( ) ) ,
245290 Throws . TypeOf < IngressError > ( ) . With . Message . Contains ( "shape does not match enumerable length" )
246291 ) ;
247-
292+
248293 Assert . That (
249- ( ) => sender . Column ( "array" , new [ ] { 1.2 , 2.6 , 3.1 , 4.6 } . AsEnumerable ( ) , new [ ] { - 1 , 4 } . AsEnumerable ( ) ) ,
294+ ( ) => sender . Column ( "array" , new [ ]
295+ {
296+ 1.2 , 2.6 ,
297+ 3.1 , 4.6 ,
298+ } . AsEnumerable ( ) , new [ ]
299+ {
300+ - 1 , 4 ,
301+ } . AsEnumerable ( ) ) ,
250302 Throws . TypeOf < IngressError > ( ) . With . Message . Contains ( "array shape is invalid" )
251303 ) ;
252304 }
@@ -263,7 +315,11 @@ await sender.Table("metrics")
263315 . Symbol ( "tag" , "value" )
264316 . Column ( "number" , 10 )
265317 . Column ( "string" , "abc" )
266- . Column ( "array" , new [ ] { 1.2 , 2.6 , 3.1 , 4.6 } )
318+ . Column ( "array" , new [ ]
319+ {
320+ 1.2 , 2.6 ,
321+ 3.1 , 4.6 ,
322+ } )
267323 . AtAsync ( new DateTime ( 1970 , 01 , 01 , 0 , 0 , 1 ) ) ;
268324
269325 await sender . SendAsync ( ) ;
@@ -622,7 +678,10 @@ await sender.Table("table name")
622678 }
623679
624680 // ReSharper disable once DisposeOnUsingVariable
625- if ( i == 1 ) srv . Dispose ( ) ;
681+ if ( i == 1 )
682+ {
683+ srv . Dispose ( ) ;
684+ }
626685 }
627686 }
628687
@@ -840,7 +899,10 @@ await sender.Table(metric)
840899 . AtAsync ( new DateTime ( 2021 , 1 , 1 , i / 360 / 1000 % 60 , i / 60 / 1000 % 60 , i / 1000 % 60 ,
841900 i % 1000 ) ) ;
842901
843- if ( i % 100 == 0 ) await sender . SendAsync ( ) ;
902+ if ( i % 100 == 0 )
903+ {
904+ await sender . SendAsync ( ) ;
905+ }
844906 }
845907
846908 await sender . SendAsync ( ) ;
@@ -993,7 +1055,7 @@ public async Task CancelLine()
9931055 Assert . That ( srv . PrintBuffer ( ) , Is . EqualTo ( expected ) ) ;
9941056 }
9951057
996-
1058+
9971059 [ Test ]
9981060 public async Task CancelLineAfterClear ( )
9991061 {
@@ -1019,7 +1081,33 @@ public async Task CancelLineAfterClear()
10191081 var expected = "good 86400000000000\n " ;
10201082 Assert . That ( srv . PrintBuffer ( ) , Is . EqualTo ( expected ) ) ;
10211083 }
1022-
1084+
1085+
1086+ [ Test ]
1087+ public async Task CancelLineAfterError ( )
1088+ {
1089+ using var srv = new DummyHttpServer ( ) ;
1090+
1091+ var sender = Sender . New ( $ "http::addr={ Host } :{ HttpPort } ;auto_flush=off;protocol_version=1;") ;
1092+ await sender . Table ( "foo" ) . Symbol ( "a" , "b" ) . AtNowAsync ( ) ;
1093+ await sender . Table ( "foo123" ) . Symbol ( "a" , "b" ) . AtNowAsync ( ) ;
1094+
1095+ Assert . That (
1096+ async ( ) => { await sender . SendAsync ( ) ; } ,
1097+ Throws . TypeOf < IngressError > ( ) . With . Message . Contains ( "Cannot connect" )
1098+ ) ;
1099+
1100+ sender . CancelRow ( ) ;
1101+ await srv . StartAsync ( HttpPort ) ;
1102+
1103+ await sender . Table ( "good" ) . Symbol ( "a" , "b" ) . AtAsync ( 86400000000000 ) ;
1104+ await sender . SendAsync ( ) ;
1105+
1106+ var expected = "good,a=b 86400000000000\n " ;
1107+ Assert . That ( srv . PrintBuffer ( ) , Is . EqualTo ( expected ) ) ;
1108+ }
1109+
1110+
10231111 [ Test ]
10241112 public async Task CannotConnect ( )
10251113 {
@@ -1276,7 +1364,10 @@ public async Task AutoFlushRows()
12761364
12771365 for ( var i = 0 ; i < 100000 ; i ++ )
12781366 {
1279- if ( ( i - 1 ) % 100 == 0 && i != 0 ) Assert . That ( sender . Length == 32 ) ;
1367+ if ( ( i - 1 ) % 100 == 0 && i != 0 )
1368+ {
1369+ Assert . That ( sender . Length == 32 ) ;
1370+ }
12801371
12811372 await sender . Table ( "foo" ) . Symbol ( "bah" , "baz" ) . AtAsync ( DateTime . UtcNow ) ;
12821373 }
@@ -1292,7 +1383,10 @@ public async Task AutoFlushBytes()
12921383 $ "http::addr={ Host } :{ HttpPort } ;auto_flush=on;auto_flush_bytes=3200;auto_flush_interval=off;auto_flush_rows=off;") ;
12931384 for ( var i = 0 ; i < 100000 ; i ++ )
12941385 {
1295- if ( i % 100 == 0 ) Assert . That ( sender . Length == 0 ) ;
1386+ if ( i % 100 == 0 )
1387+ {
1388+ Assert . That ( sender . Length == 0 ) ;
1389+ }
12961390
12971391 await sender . Table ( "foo" ) . Symbol ( "bah" , "baz" ) . AtAsync ( DateTime . UtcNow ) ;
12981392 }
0 commit comments