11namespace PolylineAlgorithm . Abstraction . Tests . Internal ;
22
33using PolylineAlgorithm . Abstraction . Internal ;
4+ using static PolylineAlgorithm . Abstraction . Internal . Defaults . Coordinate ;
45
56[ TestClass ]
67public class CoordinateVarianceTests {
@@ -12,6 +13,27 @@ public class CoordinateVarianceTests {
1213 ( 10 , 10 )
1314 ] ;
1415
16+ public static IEnumerable < ( ( int Latitude , int Longitude ) Initial , ( int Latitude , int Longitude ) Next , ( int Latitude , int Longitude ) Result ) > Variances => [
17+ ( ( 10 , 10 ) , ( - 20 , - 20 ) , ( - 30 , - 30 ) ) ,
18+ ( ( - 10 , - 10 ) , ( 20 , 20 ) , ( 30 , 30 ) ) ,
19+ ( ( 0 , 10 ) , ( 10 , - 10 ) , ( 10 , - 20 ) ) ,
20+ ( ( 0 , - 10 ) , ( 10 , 10 ) , ( 10 , 20 ) ) ,
21+ ( ( 10 , 0 ) , ( 10 , - 10 ) , ( 0 , - 10 ) ) ,
22+ ( ( - 10 , 0 ) , ( 10 , 10 ) , ( 20 , 10 ) ) ,
23+ ( ( 10 , - 10 ) , ( - 10 , 10 ) , ( - 20 , 20 ) ) ,
24+ ( ( - 10 , 10 ) , ( 10 , 10 ) , ( 20 , 0 ) ) ,
25+ ( ( 10 , 10 ) , ( 10 , 0 ) , ( 0 , - 10 ) ) ,
26+ ( ( - 10 , - 10 ) , ( - 10 , 0 ) , ( 0 , 10 ) ) ,
27+ ( ( 10 , 10 ) , ( 0 , 0 ) , ( - 10 , - 10 ) ) ,
28+ ( ( - 10 , - 10 ) , ( 0 , 0 ) , ( 10 , 10 ) ) ,
29+ ( ( 10 , - 10 ) , ( 0 , 0 ) , ( - 10 , 10 ) ) ,
30+ ( ( - 10 , 10 ) , ( 0 , 0 ) , ( 10 , - 10 ) ) ,
31+ ( ( 0 , 10 ) , ( 0 , 0 ) , ( 0 , - 10 ) ) ,
32+ ( ( 0 , - 10 ) , ( 0 , 0 ) , ( 0 , 10 ) ) ,
33+ ( ( 10 , 0 ) , ( 0 , 0 ) , ( - 10 , 0 ) ) ,
34+ ( ( - 10 , 0 ) , ( 0 , 0 ) , ( 10 , 0 ) )
35+ ] ;
36+
1537 [ TestMethod ]
1638 public void Constructor_Sets_Defaults ( ) {
1739 // Arrange & Act
@@ -23,7 +45,7 @@ public void Constructor_Sets_Defaults() {
2345
2446 [ TestMethod ]
2547 [ DynamicData ( nameof ( Coordinates ) , DynamicDataSourceType . Property ) ]
26- public void Next_Calculates_Correct_Variance ( int latitude , int longitude ) {
48+ public void Next_Calculates_Correct_Variance_From_Default_Variance ( int latitude , int longitude ) {
2749 // Arrange
2850 CoordinateVariance variance = new ( ) ;
2951 var expected = ( latitude , longitude ) ;
@@ -35,4 +57,19 @@ public void Next_Calculates_Correct_Variance(int latitude, int longitude) {
3557 Assert . AreEqual ( expected . latitude , variance . Latitude ) ;
3658 Assert . AreEqual ( expected . longitude , variance . Longitude ) ;
3759 }
60+
61+ [ TestMethod ]
62+ [ DynamicData ( nameof ( Variances ) , DynamicDataSourceType . Property ) ]
63+ public void Next_Calculates_Correct_Variance_From_Previous_Variance ( ( int Latitude , int Longitude ) initial , ( int Latitude , int Longitude ) next , ( int Latitude , int Longitude ) expected ) {
64+ // Arrange
65+ CoordinateVariance variance = new ( ) ;
66+ variance . Next ( initial . Latitude , initial . Longitude ) ;
67+
68+ // Act
69+ variance . Next ( next . Latitude , next . Longitude ) ;
70+
71+ // Assert
72+ Assert . AreEqual ( expected . Latitude , variance . Latitude ) ;
73+ Assert . AreEqual ( expected . Longitude , variance . Longitude ) ;
74+ }
3875}
0 commit comments