Skip to content

Commit 39c7ae8

Browse files
Add hamming
1 parent 0c5a6c5 commit 39c7ae8

File tree

2 files changed

+25
-10
lines changed

2 files changed

+25
-10
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using Xunit;
2+
3+
public class HammingTests
4+
{
5+
{{#test_cases}}
6+
[Fact{{#unless @first}}(Skip = "Remove this Skip property to run this test"){{/unless}}]
7+
public void {{method_name path}}()
8+
{
9+
{{#if error}}
10+
Assert.Throws<ArgumentException>(() => Hamming.Distance({{input.strand1}}, {{input.strand2}}));
11+
{{else}}
12+
Assert.Equal({{expected}}, Hamming.Distance({{input.strand1}}, {{input.strand2}}));
13+
{{/if}}
14+
}
15+
{{/test_cases}}
16+
}

exercises/practice/hamming/HammingTests.cs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,57 @@
1-
using System;
21
using Xunit;
32

43
public class HammingTests
54
{
65
[Fact]
7-
public void Empty_strands()
6+
public void EmptyStrands()
87
{
98
Assert.Equal(0, Hamming.Distance("", ""));
109
}
1110

1211
[Fact(Skip = "Remove this Skip property to run this test")]
13-
public void Single_letter_identical_strands()
12+
public void SingleLetterIdenticalStrands()
1413
{
1514
Assert.Equal(0, Hamming.Distance("A", "A"));
1615
}
1716

1817
[Fact(Skip = "Remove this Skip property to run this test")]
19-
public void Single_letter_different_strands()
18+
public void SingleLetterDifferentStrands()
2019
{
2120
Assert.Equal(1, Hamming.Distance("G", "T"));
2221
}
2322

2423
[Fact(Skip = "Remove this Skip property to run this test")]
25-
public void Long_identical_strands()
24+
public void LongIdenticalStrands()
2625
{
2726
Assert.Equal(0, Hamming.Distance("GGACTGAAATCTG", "GGACTGAAATCTG"));
2827
}
2928

3029
[Fact(Skip = "Remove this Skip property to run this test")]
31-
public void Long_different_strands()
30+
public void LongDifferentStrands()
3231
{
3332
Assert.Equal(9, Hamming.Distance("GGACGGATTCTG", "AGGACGGATTCT"));
3433
}
3534

3635
[Fact(Skip = "Remove this Skip property to run this test")]
37-
public void Disallow_first_strand_longer()
36+
public void DisallowFirstStrandLonger()
3837
{
3938
Assert.Throws<ArgumentException>(() => Hamming.Distance("AATG", "AAA"));
4039
}
4140

4241
[Fact(Skip = "Remove this Skip property to run this test")]
43-
public void Disallow_second_strand_longer()
42+
public void DisallowSecondStrandLonger()
4443
{
4544
Assert.Throws<ArgumentException>(() => Hamming.Distance("ATA", "AGTG"));
4645
}
4746

4847
[Fact(Skip = "Remove this Skip property to run this test")]
49-
public void Disallow_empty_first_strand()
48+
public void DisallowEmptyFirstStrand()
5049
{
5150
Assert.Throws<ArgumentException>(() => Hamming.Distance("", "G"));
5251
}
5352

5453
[Fact(Skip = "Remove this Skip property to run this test")]
55-
public void Disallow_empty_second_strand()
54+
public void DisallowEmptySecondStrand()
5655
{
5756
Assert.Throws<ArgumentException>(() => Hamming.Distance("G", ""));
5857
}

0 commit comments

Comments
 (0)