@@ -53,11 +53,11 @@ public void RadiusMustBeGreaterThan0(float radius, bool throws)
5353 [ Fact ]
5454 public void GeneratesCorrectPath ( )
5555 {
56- const float Radius = 5 ;
57- const float Radius2 = 30 ;
56+ const float radius = 5 ;
57+ const float radius2 = 30 ;
5858 int pointsCount = new Random ( ) . Next ( 3 , 20 ) ;
5959
60- Star poly = new ( Vector2 . Zero , pointsCount , Radius , Radius2 , 0 ) ;
60+ Star poly = new ( Vector2 . Zero , pointsCount , radius , radius2 , 0 ) ;
6161
6262 PointF [ ] points = poly . Flatten ( ) . ToArray ( ) [ 0 ] . Points . ToArray ( ) ;
6363
@@ -78,29 +78,35 @@ public void GeneratesCorrectPath()
7878 Assert . Equal ( baseline , actual , 3F ) ;
7979 if ( i % 2 == 1 )
8080 {
81- Assert . Equal ( Radius , Vector2 . Distance ( Vector2 . Zero , points [ i ] ) , 3F ) ;
81+ Assert . Equal ( radius , Vector2 . Distance ( Vector2 . Zero , points [ i ] ) , 3F ) ;
8282 }
8383 else
8484 {
85- Assert . Equal ( Radius2 , Vector2 . Distance ( Vector2 . Zero , points [ i ] ) , 3F ) ;
85+ Assert . Equal ( radius2 , Vector2 . Distance ( Vector2 . Zero , points [ i ] ) , 3F ) ;
8686 }
8787 }
8888 }
8989
9090 [ Fact ]
9191 public void AngleChangesOnePointToStartAtThatPosition ( )
9292 {
93- const float Radius = 10 ;
94- const float Radius2 = 20 ;
93+ const float radius = 10 ;
94+ const float radius2 = 20 ;
95+ const double tolerance = 1e-3D ;
9596 double anAngleDegrees = new Random ( ) . NextDouble ( ) * 360D ;
97+ double expectedAngleDegrees = anAngleDegrees + 90D ;
98+ if ( expectedAngleDegrees >= 360D )
99+ {
100+ expectedAngleDegrees -= 360D ;
101+ }
96102
97- Star poly = new ( Vector2 . Zero , 3 , Radius , Radius2 , ( float ) anAngleDegrees ) ;
98- ISimplePath [ ] points = poly . Flatten ( ) . ToArray ( ) ;
103+ Star poly = new ( Vector2 . Zero , 3 , radius , radius2 , ( float ) anAngleDegrees ) ;
104+ ISimplePath [ ] points = [ .. poly . Flatten ( ) ] ;
99105
100106 IEnumerable < double > allAngles = points [ 0 ] . Points . ToArray ( )
101107 . Select ( b => GeometryUtilities . RadianToDegree ( ( float ) Math . Atan2 ( b . Y , b . X ) ) )
102108 . Select ( x => x < 0 ? x + 360D : x ) ; // normalise it from +/- 180 to 0 to 360
103109
104- Assert . Contains ( allAngles , a => Math . Abs ( a - anAngleDegrees ) < 0.000001 ) ;
110+ Assert . Contains ( allAngles , a => Math . Abs ( a - expectedAngleDegrees ) < tolerance ) ;
105111 }
106112}
0 commit comments