@@ -9,8 +9,8 @@ namespace PolylineAlgorithm.Tests;
99using System ;
1010
1111/// <summary>
12- /// Tests for <see cref="FormatterBuilder{T}"/>, <see cref="PolylineFormatter {T}"/>,
13- /// and <see cref="PolylineOptions{T }"/>.
12+ /// Tests for <see cref="FormatterBuilder{T}"/>, <see cref="PolylineValueFormatter {T}"/>,
13+ /// and <see cref="PolylineOptions{TValue,TPolyline }"/>.
1414/// </summary>
1515[ TestClass ]
1616public sealed class PolylineFormatterTests {
@@ -105,7 +105,7 @@ public void AddValue_Returns_Same_Builder_For_Method_Chaining() {
105105 [ TestMethod ]
106106 public void AddValue_With_Different_Names_Succeeds ( ) {
107107 // Arrange & Act
108- PolylineFormatter < ( double X , double Y ) > formatter = FormatterBuilder < ( double X , double Y ) > . Create ( )
108+ PolylineValueFormatter < ( double X , double Y ) > formatter = FormatterBuilder < ( double X , double Y ) > . Create ( )
109109 . AddValue ( "X" , static t => t . X )
110110 . AddValue ( "Y" , static t => t . Y )
111111 . Build ( ) ;
@@ -147,7 +147,7 @@ public void SetBaseline_Returns_Same_Builder_For_Method_Chaining() {
147147 [ TestMethod ]
148148 public void SetBaseline_Applies_Only_To_Last_Added_Rule ( ) {
149149 // Arrange & Act
150- PolylineFormatter < ( double X , double Y ) > formatter = FormatterBuilder < ( double X , double Y ) > . Create ( )
150+ PolylineValueFormatter < ( double X , double Y ) > formatter = FormatterBuilder < ( double X , double Y ) > . Create ( )
151151 . AddValue ( "X" , static t => t . X )
152152 . AddValue ( "Y" , static t => t . Y )
153153 . SetBaseline ( 500L )
@@ -161,7 +161,7 @@ public void SetBaseline_Applies_Only_To_Last_Added_Rule() {
161161 [ TestMethod ]
162162 public void SetBaseline_Can_Be_Called_On_Each_Rule ( ) {
163163 // Arrange & Act
164- PolylineFormatter < ( double X , double Y ) > formatter = FormatterBuilder < ( double X , double Y ) > . Create ( )
164+ PolylineValueFormatter < ( double X , double Y ) > formatter = FormatterBuilder < ( double X , double Y ) > . Create ( )
165165 . AddValue ( "X" , static t => t . X ) . SetBaseline ( 100L )
166166 . AddValue ( "Y" , static t => t . Y ) . SetBaseline ( 200L )
167167 . Build ( ) ;
@@ -191,21 +191,21 @@ public void Build_With_Multiple_Invocations_Returns_Different_Instances() {
191191 . AddValue ( "X" , static t => t . X ) ;
192192
193193 // Act
194- PolylineFormatter < ( double X , double Y ) > first = builder . Build ( ) ;
195- PolylineFormatter < ( double X , double Y ) > second = builder . Build ( ) ;
194+ PolylineValueFormatter < ( double X , double Y ) > first = builder . Build ( ) ;
195+ PolylineValueFormatter < ( double X , double Y ) > second = builder . Build ( ) ;
196196
197197 // Assert
198198 Assert . AreNotSame ( first , second ) ;
199199 }
200200
201201 // ---------------------------------------------------------------------------
202- // PolylineFormatter <T>.Width
202+ // PolylineValueFormatter <T>.Width
203203 // ---------------------------------------------------------------------------
204204
205205 [ TestMethod ]
206206 public void Width_Equals_Number_Of_Added_Rules ( ) {
207207 // Arrange & Act
208- PolylineFormatter < ( double X , double Y , double Z ) > formatter = FormatterBuilder < ( double X , double Y , double Z ) > . Create ( )
208+ PolylineValueFormatter < ( double X , double Y , double Z ) > formatter = FormatterBuilder < ( double X , double Y , double Z ) > . Create ( )
209209 . AddValue ( "X" , static t => t . X )
210210 . AddValue ( "Y" , static t => t . Y )
211211 . AddValue ( "Z" , static t => t . Z )
@@ -218,7 +218,7 @@ public void Width_Equals_Number_Of_Added_Rules() {
218218 [ TestMethod ]
219219 public void Width_Is_One_For_Single_Rule ( ) {
220220 // Arrange & Act
221- PolylineFormatter < double > formatter = FormatterBuilder < double > . Create ( )
221+ PolylineValueFormatter < double > formatter = FormatterBuilder < double > . Create ( )
222222 . AddValue ( "Value" , static v => v )
223223 . Build ( ) ;
224224
@@ -227,13 +227,13 @@ public void Width_Is_One_For_Single_Rule() {
227227 }
228228
229229 // ---------------------------------------------------------------------------
230- // PolylineFormatter <T>.HasBaselines
230+ // PolylineValueFormatter <T>.HasBaselines
231231 // ---------------------------------------------------------------------------
232232
233233 [ TestMethod ]
234234 public void HasBaselines_Is_False_When_No_Baselines_Are_Set ( ) {
235235 // Arrange & Act
236- PolylineFormatter < ( double X , double Y ) > formatter = FormatterBuilder < ( double X , double Y ) > . Create ( )
236+ PolylineValueFormatter < ( double X , double Y ) > formatter = FormatterBuilder < ( double X , double Y ) > . Create ( )
237237 . AddValue ( "X" , static t => t . X )
238238 . AddValue ( "Y" , static t => t . Y )
239239 . Build ( ) ;
@@ -245,7 +245,7 @@ public void HasBaselines_Is_False_When_No_Baselines_Are_Set() {
245245 [ TestMethod ]
246246 public void HasBaselines_Is_True_When_Any_Baseline_Is_Set ( ) {
247247 // Arrange & Act
248- PolylineFormatter < ( double X , double Y ) > formatter = FormatterBuilder < ( double X , double Y ) > . Create ( )
248+ PolylineValueFormatter < ( double X , double Y ) > formatter = FormatterBuilder < ( double X , double Y ) > . Create ( )
249249 . AddValue ( "X" , static t => t . X )
250250 . AddValue ( "Y" , static t => t . Y ) . SetBaseline ( 100L )
251251 . Build ( ) ;
@@ -257,7 +257,7 @@ public void HasBaselines_Is_True_When_Any_Baseline_Is_Set() {
257257 [ TestMethod ]
258258 public void HasBaselines_Is_True_When_All_Baselines_Are_Set ( ) {
259259 // Arrange & Act
260- PolylineFormatter < ( double X , double Y ) > formatter = FormatterBuilder < ( double X , double Y ) > . Create ( )
260+ PolylineValueFormatter < ( double X , double Y ) > formatter = FormatterBuilder < ( double X , double Y ) > . Create ( )
261261 . AddValue ( "X" , static t => t . X ) . SetBaseline ( 10L )
262262 . AddValue ( "Y" , static t => t . Y ) . SetBaseline ( 20L )
263263 . Build ( ) ;
@@ -267,13 +267,13 @@ public void HasBaselines_Is_True_When_All_Baselines_Are_Set() {
267267 }
268268
269269 // ---------------------------------------------------------------------------
270- // PolylineFormatter <T>.GetBaseline
270+ // PolylineValueFormatter <T>.GetBaseline
271271 // ---------------------------------------------------------------------------
272272
273273 [ TestMethod ]
274274 public void GetBaseline_Returns_Zero_When_No_Baseline_Configured ( ) {
275275 // Arrange
276- PolylineFormatter < double > formatter = FormatterBuilder < double > . Create ( )
276+ PolylineValueFormatter < double > formatter = FormatterBuilder < double > . Create ( )
277277 . AddValue ( "Value" , static v => v )
278278 . Build ( ) ;
279279
@@ -287,7 +287,7 @@ public void GetBaseline_Returns_Zero_When_No_Baseline_Configured() {
287287 [ TestMethod ]
288288 public void GetBaseline_Returns_Configured_Baseline ( ) {
289289 // Arrange
290- PolylineFormatter < double > formatter = FormatterBuilder < double > . Create ( )
290+ PolylineValueFormatter < double > formatter = FormatterBuilder < double > . Create ( )
291291 . AddValue ( "Value" , static v => v )
292292 . SetBaseline ( 42L )
293293 . Build ( ) ;
@@ -302,7 +302,7 @@ public void GetBaseline_Returns_Configured_Baseline() {
302302 [ TestMethod ]
303303 public void GetBaseline_Returns_Negative_Baseline ( ) {
304304 // Arrange
305- PolylineFormatter < double > formatter = FormatterBuilder < double > . Create ( )
305+ PolylineValueFormatter < double > formatter = FormatterBuilder < double > . Create ( )
306306 . AddValue ( "Value" , static v => v )
307307 . SetBaseline ( - 1000L )
308308 . Build ( ) ;
@@ -315,13 +315,13 @@ public void GetBaseline_Returns_Negative_Baseline() {
315315 }
316316
317317 // ---------------------------------------------------------------------------
318- // PolylineFormatter <T>.GetValues
318+ // PolylineValueFormatter <T>.GetValues
319319 // ---------------------------------------------------------------------------
320320
321321 [ TestMethod ]
322322 public void GetValues_Scales_Single_Column_By_Factor ( ) {
323323 // Arrange — precision 5 → factor = 100000; use a value exact in double arithmetic
324- PolylineFormatter < double > formatter = FormatterBuilder < double > . Create ( )
324+ PolylineValueFormatter < double > formatter = FormatterBuilder < double > . Create ( )
325325 . AddValue ( "Value" , static v => v , precision : 5 )
326326 . Build ( ) ;
327327
@@ -337,7 +337,7 @@ public void GetValues_Scales_Single_Column_By_Factor() {
337337 [ TestMethod ]
338338 public void GetValues_Scales_Multiple_Columns_Independently ( ) {
339339 // Arrange
340- PolylineFormatter < ( double Lat , double Lon ) > formatter =
340+ PolylineValueFormatter < ( double Lat , double Lon ) > formatter =
341341 FormatterBuilder < ( double Lat , double Lon ) > . Create ( )
342342 . AddValue ( "Lat" , static t => t . Lat , precision : 5 )
343343 . AddValue ( "Lon" , static t => t . Lon , precision : 5 )
@@ -356,7 +356,7 @@ public void GetValues_Scales_Multiple_Columns_Independently() {
356356 [ TestMethod ]
357357 public void GetValues_With_Wrong_Buffer_Length_Throws_ArgumentException ( ) {
358358 // Arrange — formatter has Width = 2 but buffer has length 1
359- PolylineFormatter < ( double X , double Y ) > formatter = FormatterBuilder < ( double X , double Y ) > . Create ( )
359+ PolylineValueFormatter < ( double X , double Y ) > formatter = FormatterBuilder < ( double X , double Y ) > . Create ( )
360360 . AddValue ( "X" , static t => t . X )
361361 . AddValue ( "Y" , static t => t . Y )
362362 . Build ( ) ;
@@ -372,7 +372,7 @@ public void GetValues_With_Wrong_Buffer_Length_Throws_ArgumentException() {
372372 [ TestMethod ]
373373 public void GetValues_With_Oversized_Buffer_Throws_ArgumentException ( ) {
374374 // Arrange — formatter has Width = 1 but buffer has length 3
375- PolylineFormatter < double > formatter = FormatterBuilder < double > . Create ( )
375+ PolylineValueFormatter < double > formatter = FormatterBuilder < double > . Create ( )
376376 . AddValue ( "Value" , static v => v )
377377 . Build ( ) ;
378378
@@ -387,7 +387,7 @@ public void GetValues_With_Oversized_Buffer_Throws_ArgumentException() {
387387 [ TestMethod ]
388388 public void GetValues_With_Zero_Returns_Zero ( ) {
389389 // Arrange
390- PolylineFormatter < double > formatter = FormatterBuilder < double > . Create ( )
390+ PolylineValueFormatter < double > formatter = FormatterBuilder < double > . Create ( )
391391 . AddValue ( "Value" , static v => v , precision : 5 )
392392 . Build ( ) ;
393393
@@ -403,7 +403,7 @@ public void GetValues_With_Zero_Returns_Zero() {
403403 [ TestMethod ]
404404 public void GetValues_With_Negative_Value_Returns_Negative_Scaled_Long ( ) {
405405 // Arrange
406- PolylineFormatter < double > formatter = FormatterBuilder < double > . Create ( )
406+ PolylineValueFormatter < double > formatter = FormatterBuilder < double > . Create ( )
407407 . AddValue ( "Value" , static v => v , precision : 5 )
408408 . Build ( ) ;
409409
@@ -419,7 +419,7 @@ public void GetValues_With_Negative_Value_Returns_Negative_Scaled_Long() {
419419 [ TestMethod ]
420420 public void GetValues_With_Custom_Precision_Scales_Correctly ( ) {
421421 // Arrange — precision 3 → factor = 1000
422- PolylineFormatter < double > formatter = FormatterBuilder < double > . Create ( )
422+ PolylineValueFormatter < double > formatter = FormatterBuilder < double > . Create ( )
423423 . AddValue ( "Value" , static v => v , precision : 3 )
424424 . Build ( ) ;
425425
@@ -433,44 +433,71 @@ public void GetValues_With_Custom_Precision_Scales_Correctly() {
433433 }
434434
435435 // ---------------------------------------------------------------------------
436- // PolylineOptions<T > constructor validation
436+ // PolylineOptions<TValue,TPolyline > constructor validation
437437 // ---------------------------------------------------------------------------
438438
439439 [ TestMethod ]
440- public void PolylineOptions_With_Null_Formatter_Throws_ArgumentNullException ( ) {
440+ public void PolylineOptions_With_Null_ValueFormatter_Throws_ArgumentNullException ( ) {
441441 // Act & Assert
442442 ArgumentNullException ex = Assert . ThrowsExactly < ArgumentNullException > (
443- ( ) => _ = new PolylineOptions < double > ( null ! ) ) ;
444- Assert . AreEqual ( "formatter" , ex . ParamName ) ;
443+ ( ) => _ = new PolylineOptions < double , string > ( null ! , PolylineFormatter . ForString ) ) ;
444+ Assert . AreEqual ( "valueFormatter" , ex . ParamName ) ;
445+ }
446+
447+ [ TestMethod ]
448+ public void PolylineOptions_With_Null_PolylineFormatter_Throws_ArgumentNullException ( ) {
449+ // Arrange
450+ PolylineValueFormatter < double > formatter = FormatterBuilder < double > . Create ( )
451+ . AddValue ( "Value" , static v => v )
452+ . Build ( ) ;
453+
454+ // Act & Assert
455+ ArgumentNullException ex = Assert . ThrowsExactly < ArgumentNullException > (
456+ ( ) => _ = new PolylineOptions < double , string > ( formatter , null ! ) ) ;
457+ Assert . AreEqual ( "polylineFormatter" , ex . ParamName ) ;
445458 }
446459
447460 // ---------------------------------------------------------------------------
448- // PolylineOptions<T > properties
461+ // PolylineOptions<TValue,TPolyline > properties
449462 // ---------------------------------------------------------------------------
450463
451464 [ TestMethod ]
452- public void PolylineOptions_Stores_Formatter ( ) {
465+ public void PolylineOptions_Stores_ValueFormatter ( ) {
466+ // Arrange
467+ PolylineValueFormatter < double > formatter = FormatterBuilder < double > . Create ( )
468+ . AddValue ( "Value" , static v => v )
469+ . Build ( ) ;
470+
471+ // Act
472+ PolylineOptions < double , string > options = new ( formatter , PolylineFormatter . ForString ) ;
473+
474+ // Assert
475+ Assert . AreSame ( formatter , options . ValueFormatter ) ;
476+ }
477+
478+ [ TestMethod ]
479+ public void PolylineOptions_Stores_PolylineFormatter ( ) {
453480 // Arrange
454- PolylineFormatter < double > formatter = FormatterBuilder < double > . Create ( )
481+ PolylineValueFormatter < double > formatter = FormatterBuilder < double > . Create ( )
455482 . AddValue ( "Value" , static v => v )
456483 . Build ( ) ;
457484
458485 // Act
459- PolylineOptions < double > options = new ( formatter ) ;
486+ PolylineOptions < double , string > options = new ( formatter , PolylineFormatter . ForString ) ;
460487
461488 // Assert
462- Assert . AreSame ( formatter , options . Formatter ) ;
489+ Assert . AreSame ( PolylineFormatter . ForString , options . PolylineFormatter ) ;
463490 }
464491
465492 [ TestMethod ]
466493 public void PolylineOptions_With_Null_Encoding_Uses_Default_Options ( ) {
467494 // Arrange
468- PolylineFormatter < double > formatter = FormatterBuilder < double > . Create ( )
495+ PolylineValueFormatter < double > formatter = FormatterBuilder < double > . Create ( )
469496 . AddValue ( "Value" , static v => v )
470497 . Build ( ) ;
471498
472499 // Act
473- PolylineOptions < double > options = new ( formatter , null ) ;
500+ PolylineOptions < double , string > options = new ( formatter , PolylineFormatter . ForString , null ) ;
474501
475502 // Assert
476503 Assert . IsNotNull ( options . Encoding ) ;
@@ -481,7 +508,7 @@ public void PolylineOptions_With_Null_Encoding_Uses_Default_Options() {
481508 [ TestMethod ]
482509 public void PolylineOptions_Stores_Custom_Encoding_Options ( ) {
483510 // Arrange
484- PolylineFormatter < double > formatter = FormatterBuilder < double > . Create ( )
511+ PolylineValueFormatter < double > formatter = FormatterBuilder < double > . Create ( )
485512 . AddValue ( "Value" , static v => v )
486513 . Build ( ) ;
487514 PolylineEncodingOptions encoding = PolylineEncodingOptionsBuilder . Create ( )
@@ -490,7 +517,7 @@ public void PolylineOptions_Stores_Custom_Encoding_Options() {
490517 . Build ( ) ;
491518
492519 // Act
493- PolylineOptions < double > options = new ( formatter , encoding ) ;
520+ PolylineOptions < double , string > options = new ( formatter , PolylineFormatter . ForString , encoding ) ;
494521
495522 // Assert
496523 Assert . AreSame ( encoding , options . Encoding ) ;
0 commit comments