1- using System ;
21using Xunit ;
32
43public class PythagoreanTripletTests
54{
65 [ Fact ]
76 public void Triplets_whose_sum_is_12 ( )
87 {
9- Assert . Equal ( new [ ]
10- {
8+ ( int , int , int ) [ ] expected = [
119 ( 3 , 4 , 5 )
12- } , PythagoreanTriplet . TripletsWithSum ( 12 ) ) ;
10+ ] ;
11+ Assert . Equal ( expected , PythagoreanTriplet . TripletsWithSum ( 12 ) ) ;
1312 }
1413
1514 [ Fact ( Skip = "Remove this Skip property to run this test" ) ]
1615 public void Triplets_whose_sum_is_108 ( )
1716 {
18- Assert . Equal ( new [ ]
19- {
17+ ( int , int , int ) [ ] expected = [
2018 ( 27 , 36 , 45 )
21- } , PythagoreanTriplet . TripletsWithSum ( 108 ) ) ;
19+ ] ;
20+ Assert . Equal ( expected , PythagoreanTriplet . TripletsWithSum ( 108 ) ) ;
2221 }
2322
2423 [ Fact ( Skip = "Remove this Skip property to run this test" ) ]
2524 public void Triplets_whose_sum_is_1000 ( )
2625 {
27- Assert . Equal ( new [ ]
28- {
26+ ( int , int , int ) [ ] expected = [
2927 ( 200 , 375 , 425 )
30- } , PythagoreanTriplet . TripletsWithSum ( 1000 ) ) ;
28+ ] ;
29+ Assert . Equal ( expected , PythagoreanTriplet . TripletsWithSum ( 1000 ) ) ;
3130 }
3231
3332 [ Fact ( Skip = "Remove this Skip property to run this test" ) ]
3433 public void No_matching_triplets_for_1001 ( )
3534 {
36- Assert . Equal ( Array . Empty < ( int , int , int ) > ( ) , PythagoreanTriplet . TripletsWithSum ( 1001 ) ) ;
35+ Assert . Empty ( PythagoreanTriplet . TripletsWithSum ( 1001 ) ) ;
3736 }
3837
3938 [ Fact ( Skip = "Remove this Skip property to run this test" ) ]
4039 public void Returns_all_matching_triplets ( )
4140 {
42- Assert . Equal ( new [ ]
43- {
41+ ( int , int , int ) [ ] expected = [
4442 ( 9 , 40 , 41 ) ,
4543 ( 15 , 36 , 39 )
46- } , PythagoreanTriplet . TripletsWithSum ( 90 ) ) ;
44+ ] ;
45+ Assert . Equal ( expected , PythagoreanTriplet . TripletsWithSum ( 90 ) ) ;
4746 }
4847
4948 [ Fact ( Skip = "Remove this Skip property to run this test" ) ]
5049 public void Several_matching_triplets ( )
5150 {
52- Assert . Equal ( new [ ]
53- {
51+ ( int , int , int ) [ ] expected = [
5452 ( 40 , 399 , 401 ) ,
5553 ( 56 , 390 , 394 ) ,
5654 ( 105 , 360 , 375 ) ,
@@ -59,19 +57,20 @@ public void Several_matching_triplets()
5957 ( 168 , 315 , 357 ) ,
6058 ( 210 , 280 , 350 ) ,
6159 ( 240 , 252 , 348 )
62- } , PythagoreanTriplet . TripletsWithSum ( 840 ) ) ;
60+ ] ;
61+ Assert . Equal ( expected , PythagoreanTriplet . TripletsWithSum ( 840 ) ) ;
6362 }
6463
6564 [ Fact ( Skip = "Remove this Skip property to run this test" ) ]
6665 public void Triplets_for_large_number ( )
6766 {
68- Assert . Equal ( new [ ]
69- {
67+ ( int , int , int ) [ ] expected = [
7068 ( 1200 , 14375 , 14425 ) ,
7169 ( 1875 , 14000 , 14125 ) ,
7270 ( 5000 , 12000 , 13000 ) ,
7371 ( 6000 , 11250 , 12750 ) ,
7472 ( 7500 , 10000 , 12500 )
75- } , PythagoreanTriplet . TripletsWithSum ( 30000 ) ) ;
73+ ] ;
74+ Assert . Equal ( expected , PythagoreanTriplet . TripletsWithSum ( 30000 ) ) ;
7675 }
7776}
0 commit comments