@@ -6,201 +6,150 @@ public class AllYourBaseTests
66 [ Fact ]
77 public void Single_bit_one_to_decimal ( )
88 {
9- var inputBase = 2 ;
10- var digits = new [ ] { 1 } ;
11- var outputBase = 10 ;
12- var expected = new [ ] { 1 } ;
13- Assert . Equal ( expected , AllYourBase . Rebase ( inputBase , digits , outputBase ) ) ;
9+ int [ ] digits = [ 1 ] ;
10+ int [ ] expected = [ 1 ] ;
11+ Assert . Equal ( expected , AllYourBase . Rebase ( 2 , digits , 2 ) ) ;
1412 }
1513
1614 [ Fact ( Skip = "Remove this Skip property to run this test" ) ]
1715 public void Binary_to_single_decimal ( )
1816 {
19- var inputBase = 2 ;
20- var digits = new [ ] { 1 , 0 , 1 } ;
21- var outputBase = 10 ;
22- var expected = new [ ] { 5 } ;
23- Assert . Equal ( expected , AllYourBase . Rebase ( inputBase , digits , outputBase ) ) ;
17+ int [ ] digits = [ 1 , 0 , 1 ] ;
18+ int [ ] expected = [ 5 ] ;
19+ Assert . Equal ( expected , AllYourBase . Rebase ( 2 , digits , 2 ) ) ;
2420 }
2521
2622 [ Fact ( Skip = "Remove this Skip property to run this test" ) ]
2723 public void Single_decimal_to_binary ( )
2824 {
29- var inputBase = 10 ;
30- var digits = new [ ] { 5 } ;
31- var outputBase = 2 ;
32- var expected = new [ ] { 1 , 0 , 1 } ;
33- Assert . Equal ( expected , AllYourBase . Rebase ( inputBase , digits , outputBase ) ) ;
25+ int [ ] digits = [ 5 ] ;
26+ int [ ] expected = [ 1 , 0 , 1 ] ;
27+ Assert . Equal ( expected , AllYourBase . Rebase ( 10 , digits , 10 ) ) ;
3428 }
3529
3630 [ Fact ( Skip = "Remove this Skip property to run this test" ) ]
3731 public void Binary_to_multiple_decimal ( )
3832 {
39- var inputBase = 2 ;
40- var digits = new [ ] { 1 , 0 , 1 , 0 , 1 , 0 } ;
41- var outputBase = 10 ;
42- var expected = new [ ] { 4 , 2 } ;
43- Assert . Equal ( expected , AllYourBase . Rebase ( inputBase , digits , outputBase ) ) ;
33+ int [ ] digits = [ 1 , 0 , 1 , 0 , 1 , 0 ] ;
34+ int [ ] expected = [ 4 , 2 ] ;
35+ Assert . Equal ( expected , AllYourBase . Rebase ( 2 , digits , 2 ) ) ;
4436 }
4537
4638 [ Fact ( Skip = "Remove this Skip property to run this test" ) ]
4739 public void Decimal_to_binary ( )
4840 {
49- var inputBase = 10 ;
50- var digits = new [ ] { 4 , 2 } ;
51- var outputBase = 2 ;
52- var expected = new [ ] { 1 , 0 , 1 , 0 , 1 , 0 } ;
53- Assert . Equal ( expected , AllYourBase . Rebase ( inputBase , digits , outputBase ) ) ;
41+ int [ ] digits = [ 4 , 2 ] ;
42+ int [ ] expected = [ 1 , 0 , 1 , 0 , 1 , 0 ] ;
43+ Assert . Equal ( expected , AllYourBase . Rebase ( 10 , digits , 10 ) ) ;
5444 }
5545
5646 [ Fact ( Skip = "Remove this Skip property to run this test" ) ]
5747 public void Trinary_to_hexadecimal ( )
5848 {
59- var inputBase = 3 ;
60- var digits = new [ ] { 1 , 1 , 2 , 0 } ;
61- var outputBase = 16 ;
62- var expected = new [ ] { 2 , 10 } ;
63- Assert . Equal ( expected , AllYourBase . Rebase ( inputBase , digits , outputBase ) ) ;
49+ int [ ] digits = [ 1 , 1 , 2 , 0 ] ;
50+ int [ ] expected = [ 2 , 10 ] ;
51+ Assert . Equal ( expected , AllYourBase . Rebase ( 3 , digits , 3 ) ) ;
6452 }
6553
6654 [ Fact ( Skip = "Remove this Skip property to run this test" ) ]
6755 public void Hexadecimal_to_trinary ( )
6856 {
69- var inputBase = 16 ;
70- var digits = new [ ] { 2 , 10 } ;
71- var outputBase = 3 ;
72- var expected = new [ ] { 1 , 1 , 2 , 0 } ;
73- Assert . Equal ( expected , AllYourBase . Rebase ( inputBase , digits , outputBase ) ) ;
57+ int [ ] digits = [ 2 , 10 ] ;
58+ int [ ] expected = [ 1 , 1 , 2 , 0 ] ;
59+ Assert . Equal ( expected , AllYourBase . Rebase ( 16 , digits , 16 ) ) ;
7460 }
7561
7662 [ Fact ( Skip = "Remove this Skip property to run this test" ) ]
77- public void Number_15_bit_integer ( )
63+ public void Fifteen_bit_integer ( )
7864 {
79- var inputBase = 97 ;
80- var digits = new [ ] { 3 , 46 , 60 } ;
81- var outputBase = 73 ;
82- var expected = new [ ] { 6 , 10 , 45 } ;
83- Assert . Equal ( expected , AllYourBase . Rebase ( inputBase , digits , outputBase ) ) ;
65+ int [ ] digits = [ 3 , 46 , 60 ] ;
66+ int [ ] expected = [ 6 , 10 , 45 ] ;
67+ Assert . Equal ( expected , AllYourBase . Rebase ( 97 , digits , 97 ) ) ;
8468 }
8569
8670 [ Fact ( Skip = "Remove this Skip property to run this test" ) ]
8771 public void Empty_list ( )
8872 {
89- var inputBase = 2 ;
90- var digits = Array . Empty < int > ( ) ;
91- var outputBase = 10 ;
92- var expected = new [ ] { 0 } ;
93- Assert . Equal ( expected , AllYourBase . Rebase ( inputBase , digits , outputBase ) ) ;
73+ int [ ] digits = [ ] ;
74+ int [ ] expected = [ 0 ] ;
75+ Assert . Equal ( expected , AllYourBase . Rebase ( 2 , digits , 2 ) ) ;
9476 }
9577
9678 [ Fact ( Skip = "Remove this Skip property to run this test" ) ]
9779 public void Single_zero ( )
9880 {
99- var inputBase = 10 ;
100- var digits = new [ ] { 0 } ;
101- var outputBase = 2 ;
102- var expected = new [ ] { 0 } ;
103- Assert . Equal ( expected , AllYourBase . Rebase ( inputBase , digits , outputBase ) ) ;
81+ int [ ] digits = [ 0 ] ;
82+ int [ ] expected = [ 0 ] ;
83+ Assert . Equal ( expected , AllYourBase . Rebase ( 10 , digits , 10 ) ) ;
10484 }
10585
10686 [ Fact ( Skip = "Remove this Skip property to run this test" ) ]
10787 public void Multiple_zeros ( )
10888 {
109- var inputBase = 10 ;
110- var digits = new [ ] { 0 , 0 , 0 } ;
111- var outputBase = 2 ;
112- var expected = new [ ] { 0 } ;
113- Assert . Equal ( expected , AllYourBase . Rebase ( inputBase , digits , outputBase ) ) ;
89+ int [ ] digits = [ 0 , 0 , 0 ] ;
90+ int [ ] expected = [ 0 ] ;
91+ Assert . Equal ( expected , AllYourBase . Rebase ( 10 , digits , 10 ) ) ;
11492 }
11593
11694 [ Fact ( Skip = "Remove this Skip property to run this test" ) ]
11795 public void Leading_zeros ( )
11896 {
119- var inputBase = 7 ;
120- var digits = new [ ] { 0 , 6 , 0 } ;
121- var outputBase = 10 ;
122- var expected = new [ ] { 4 , 2 } ;
123- Assert . Equal ( expected , AllYourBase . Rebase ( inputBase , digits , outputBase ) ) ;
97+ int [ ] digits = [ 0 , 6 , 0 ] ;
98+ int [ ] expected = [ 4 , 2 ] ;
99+ Assert . Equal ( expected , AllYourBase . Rebase ( 7 , digits , 7 ) ) ;
124100 }
125101
126102 [ Fact ( Skip = "Remove this Skip property to run this test" ) ]
127103 public void Input_base_is_one ( )
128104 {
129- var inputBase = 1 ;
130- var digits = new [ ] { 0 } ;
131- var outputBase = 10 ;
132- Assert . Throws < ArgumentException > ( ( ) => AllYourBase . Rebase ( inputBase , digits , outputBase ) ) ;
105+ Assert . Throws < ArgumentException > ( ( ) => AllYourBase . Rebase ( 1 , [ 0 ] , 1 ) ) ;
133106 }
134107
135108 [ Fact ( Skip = "Remove this Skip property to run this test" ) ]
136109 public void Input_base_is_zero ( )
137110 {
138- var inputBase = 0 ;
139- var digits = Array . Empty < int > ( ) ;
140- var outputBase = 10 ;
141- Assert . Throws < ArgumentException > ( ( ) => AllYourBase . Rebase ( inputBase , digits , outputBase ) ) ;
111+ Assert . Throws < ArgumentException > ( ( ) => AllYourBase . Rebase ( 0 , [ ] , 0 ) ) ;
142112 }
143113
144114 [ Fact ( Skip = "Remove this Skip property to run this test" ) ]
145115 public void Input_base_is_negative ( )
146116 {
147- var inputBase = - 2 ;
148- var digits = new [ ] { 1 } ;
149- var outputBase = 10 ;
150- Assert . Throws < ArgumentException > ( ( ) => AllYourBase . Rebase ( inputBase , digits , outputBase ) ) ;
117+ Assert . Throws < ArgumentException > ( ( ) => AllYourBase . Rebase ( - 2 , [ 1 ] , - 2 ) ) ;
151118 }
152119
153120 [ Fact ( Skip = "Remove this Skip property to run this test" ) ]
154121 public void Negative_digit ( )
155122 {
156- var inputBase = 2 ;
157- var digits = new [ ] { 1 , - 1 , 1 , 0 , 1 , 0 } ;
158- var outputBase = 10 ;
159- Assert . Throws < ArgumentException > ( ( ) => AllYourBase . Rebase ( inputBase , digits , outputBase ) ) ;
123+ Assert . Throws < ArgumentException > ( ( ) => AllYourBase . Rebase ( 2 , [ 1 , - 1 , 1 , 0 , 1 , 0 ] , 2 ) ) ;
160124 }
161125
162126 [ Fact ( Skip = "Remove this Skip property to run this test" ) ]
163127 public void Invalid_positive_digit ( )
164128 {
165- var inputBase = 2 ;
166- var digits = new [ ] { 1 , 2 , 1 , 0 , 1 , 0 } ;
167- var outputBase = 10 ;
168- Assert . Throws < ArgumentException > ( ( ) => AllYourBase . Rebase ( inputBase , digits , outputBase ) ) ;
129+ Assert . Throws < ArgumentException > ( ( ) => AllYourBase . Rebase ( 2 , [ 1 , 2 , 1 , 0 , 1 , 0 ] , 2 ) ) ;
169130 }
170131
171132 [ Fact ( Skip = "Remove this Skip property to run this test" ) ]
172133 public void Output_base_is_one ( )
173134 {
174- var inputBase = 2 ;
175- var digits = new [ ] { 1 , 0 , 1 , 0 , 1 , 0 } ;
176- var outputBase = 1 ;
177- Assert . Throws < ArgumentException > ( ( ) => AllYourBase . Rebase ( inputBase , digits , outputBase ) ) ;
135+ Assert . Throws < ArgumentException > ( ( ) => AllYourBase . Rebase ( 2 , [ 1 , 0 , 1 , 0 , 1 , 0 ] , 2 ) ) ;
178136 }
179137
180138 [ Fact ( Skip = "Remove this Skip property to run this test" ) ]
181139 public void Output_base_is_zero ( )
182140 {
183- var inputBase = 10 ;
184- var digits = new [ ] { 7 } ;
185- var outputBase = 0 ;
186- Assert . Throws < ArgumentException > ( ( ) => AllYourBase . Rebase ( inputBase , digits , outputBase ) ) ;
141+ Assert . Throws < ArgumentException > ( ( ) => AllYourBase . Rebase ( 10 , [ 7 ] , 10 ) ) ;
187142 }
188143
189144 [ Fact ( Skip = "Remove this Skip property to run this test" ) ]
190145 public void Output_base_is_negative ( )
191146 {
192- var inputBase = 2 ;
193- var digits = new [ ] { 1 } ;
194- var outputBase = - 7 ;
195- Assert . Throws < ArgumentException > ( ( ) => AllYourBase . Rebase ( inputBase , digits , outputBase ) ) ;
147+ Assert . Throws < ArgumentException > ( ( ) => AllYourBase . Rebase ( 2 , [ 1 ] , 2 ) ) ;
196148 }
197149
198150 [ Fact ( Skip = "Remove this Skip property to run this test" ) ]
199151 public void Both_bases_are_negative ( )
200152 {
201- var inputBase = - 2 ;
202- var digits = new [ ] { 1 } ;
203- var outputBase = - 7 ;
204- Assert . Throws < ArgumentException > ( ( ) => AllYourBase . Rebase ( inputBase , digits , outputBase ) ) ;
153+ Assert . Throws < ArgumentException > ( ( ) => AllYourBase . Rebase ( - 2 , [ 1 ] , - 2 ) ) ;
205154 }
206155}
0 commit comments