@@ -39,4 +39,45 @@ public void TestRelax()
3939 Assert . That ( sites , Has . Count . EqualTo ( originalSites . Count ) ) ;
4040 // todo: check movement
4141 }
42+
43+ [ TestCase ( 1 ) ]
44+ [ TestCase ( 2 ) ] // this will tessellate in-between
45+ public void TestRelaxingShouldNotUseDuplicateSites ( int iterations )
46+ {
47+ // Arrange
48+
49+ List < VoronoiSite > originalSites =
50+ [
51+ new VoronoiSite ( 200 , 100 ) ,
52+ new VoronoiSite ( 100 , 300 ) ,
53+ new VoronoiSite ( 300 , 400 ) ,
54+ new VoronoiSite ( 400 , 200 ) ,
55+ new VoronoiSite ( 200 , 100 ) , // duplicate
56+ new VoronoiSite ( 100 , 300 ) // duplicate
57+ ] ;
58+
59+ List < VoronoiSite > sites = new List < VoronoiSite > ( originalSites ) ; // copy so any changes to list don't affect the source list
60+
61+ VoronoiPlane plane = new VoronoiPlane ( 0 , 0 , 600 , 600 ) ;
62+
63+ plane . SetSites ( sites ) ;
64+
65+ plane . Tessellate ( ) ;
66+
67+ Assert . That ( originalSites [ 0 ] . SkippedAsDuplicate , Is . False ) ;
68+ Assert . That ( originalSites [ 1 ] . SkippedAsDuplicate , Is . False ) ;
69+ Assert . That ( originalSites [ 2 ] . SkippedAsDuplicate , Is . False ) ;
70+ Assert . That ( originalSites [ 3 ] . SkippedAsDuplicate , Is . False ) ;
71+ Assert . That ( originalSites [ 4 ] . SkippedAsDuplicate , Is . True ) ;
72+ Assert . That ( originalSites [ 5 ] . SkippedAsDuplicate , Is . True ) ;
73+
74+ // Act
75+
76+ plane . Relax ( iterations ) ;
77+
78+ // Assert
79+
80+ Assert . That ( originalSites [ 4 ] . SkippedAsDuplicate , Is . True ) ;
81+ Assert . That ( originalSites [ 5 ] . SkippedAsDuplicate , Is . True ) ;
82+ }
4283}
0 commit comments