Skip to content

Commit 3078dc1

Browse files
binary: add generator
1 parent 4518b04 commit 3078dc1

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using Xunit;
2+
3+
public class {{testClass}}
4+
{
5+
{{for test in tests}}
6+
[Fact{{if !for.first}}(Skip = "Remove this Skip property to run this test"){{end}}]
7+
public void {{test.testMethod}}()
8+
{
9+
Assert.Equal({{test.expected}}, {{testedClass}}.To{{test.testedMethod}}({{test.input.binary | string.literal}}));
10+
}
11+
{{end}}
12+
}

exercises/practice/binary/BinaryTests.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using Xunit;
22

3-
public class BinaryTest
3+
public class BinaryTests
44
{
55
[Fact]
66
public void Binary_0_is_decimal_0()
@@ -57,38 +57,38 @@ public void Binary_ignores_leading_zeros()
5757
}
5858

5959
[Fact(Skip = "Remove this Skip property to run this test")]
60-
public void Invalid_binary_2_converts_to_decimal_0()
60+
public void Two_is_not_a_valid_binary_digit()
6161
{
62-
Assert.Equal(0, Binary.ToDecimal("2"));
62+
Assert.Equal(, Binary.ToDecimal("2"));
6363
}
6464

6565
[Fact(Skip = "Remove this Skip property to run this test")]
6666
public void A_number_containing_a_non_binary_digit_is_invalid()
6767
{
68-
Assert.Equal(0, Binary.ToDecimal("01201"));
68+
Assert.Equal(, Binary.ToDecimal("01201"));
6969
}
7070

7171
[Fact(Skip = "Remove this Skip property to run this test")]
7272
public void A_number_with_trailing_non_binary_characters_is_invalid()
7373
{
74-
Assert.Equal(0, Binary.ToDecimal("10nope"));
74+
Assert.Equal(, Binary.ToDecimal("10nope"));
7575
}
7676

7777
[Fact(Skip = "Remove this Skip property to run this test")]
7878
public void A_number_with_leading_non_binary_characters_is_invalid()
7979
{
80-
Assert.Equal(0, Binary.ToDecimal("nope10"));
80+
Assert.Equal(, Binary.ToDecimal("nope10"));
8181
}
8282

8383
[Fact(Skip = "Remove this Skip property to run this test")]
8484
public void A_number_with_internal_non_binary_characters_is_invalid()
8585
{
86-
Assert.Equal(0, Binary.ToDecimal("10nope10"));
86+
Assert.Equal(, Binary.ToDecimal("10nope10"));
8787
}
8888

8989
[Fact(Skip = "Remove this Skip property to run this test")]
9090
public void A_number_and_a_word_whitespace_separated_is_invalid()
9191
{
92-
Assert.Equal(0, Binary.ToDecimal("001 nope"));
92+
Assert.Equal(, Binary.ToDecimal("001 nope"));
9393
}
9494
}

0 commit comments

Comments
 (0)