Skip to content

Commit 54d2c17

Browse files
robkeimErikSchierboom
authored andcommitted
Add test generator for rna transcription exercise (#353)
* Add test generator for rna transcription exercise * Fix build error
1 parent 137af43 commit 54d2c17

6 files changed

Lines changed: 43 additions & 12 deletions

File tree

exercises/rail-fence-cipher/RailFenceCipherTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// This file was auto-generated based on version 1.0.1 of the canonical data.
1+
// This file was auto-generated based on version 1.0.1 of the canonical data.
22

33
using Xunit;
44

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
using System.Collections.Generic;
22
using System.Linq;
33

4-
public class Complement
4+
public static class RnaTranscription
55
{
66
private static readonly Dictionary<char, char> DnaToRna = new Dictionary<char, char>
77
{
88
{ 'G', 'C' }, { 'C', 'G' }, { 'T', 'A' }, { 'A', 'U' }
99
};
1010

11-
public static string OfDna(string nucleotide)
11+
public static string ToRna(string nucleotide)
1212
{
13+
if (nucleotide.Any(x => !DnaToRna.ContainsKey(x)))
14+
{
15+
return null;
16+
}
17+
1318
return string.Concat(nucleotide.Select(x => DnaToRna[x]));
1419
}
1520
}

exercises/rna-transcription/RnaTranscription.cs

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

3-
public static class Complement
3+
public static class RnaTranscription
44
{
5-
public static string OfDna(string nucleotide)
5+
public static string ToRna(string nucleotide)
66
{
77
throw new NotImplementedException("You need to implement this function.");
88
}
Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,54 @@
1+
// This file was auto-generated based on version 1.0.1 of the canonical data.
2+
13
using Xunit;
24

3-
public class ComplementTest
5+
public class RnaTranscriptionTest
46
{
57
[Fact]
68
public void Rna_complement_of_cytosine_is_guanine()
79
{
8-
Assert.Equal("G", Complement.OfDna("C"));
10+
Assert.Equal("G", RnaTranscription.ToRna("C"));
911
}
1012

1113
[Fact(Skip = "Remove to run test")]
1214
public void Rna_complement_of_guanine_is_cytosine()
1315
{
14-
Assert.Equal("C", Complement.OfDna("G"));
16+
Assert.Equal("C", RnaTranscription.ToRna("G"));
1517
}
1618

1719
[Fact(Skip = "Remove to run test")]
1820
public void Rna_complement_of_thymine_is_adenine()
1921
{
20-
Assert.Equal("A", Complement.OfDna("T"));
22+
Assert.Equal("A", RnaTranscription.ToRna("T"));
2123
}
2224

2325
[Fact(Skip = "Remove to run test")]
2426
public void Rna_complement_of_adenine_is_uracil()
2527
{
26-
Assert.Equal("U", Complement.OfDna("A"));
28+
Assert.Equal("U", RnaTranscription.ToRna("A"));
2729
}
2830

2931
[Fact(Skip = "Remove to run test")]
3032
public void Rna_complement()
3133
{
32-
Assert.Equal("UGCACCAGAAUU", Complement.OfDna("ACGTGGTCTTAA"));
34+
Assert.Equal("UGCACCAGAAUU", RnaTranscription.ToRna("ACGTGGTCTTAA"));
35+
}
36+
37+
[Fact(Skip = "Remove to run test")]
38+
public void Correctly_handles_invalid_input_rna_instead_of_dna_()
39+
{
40+
Assert.Null(RnaTranscription.ToRna("U"));
41+
}
42+
43+
[Fact(Skip = "Remove to run test")]
44+
public void Correctly_handles_completely_invalid_dna_input()
45+
{
46+
Assert.Null(RnaTranscription.ToRna("XXX"));
47+
}
48+
49+
[Fact(Skip = "Remove to run test")]
50+
public void Correctly_handles_partially_invalid_dna_input()
51+
{
52+
Assert.Null(RnaTranscription.ToRna("ACGTXXXCTTAA"));
3353
}
3454
}

exercises/two-fer/TwoFerTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// This file was auto-generated based on version 1.1.0 of the canonical data.
1+
// This file was auto-generated based on version 1.1.0 of the canonical data.
22

33
using Xunit;
44

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace Generators.Exercises
2+
{
3+
public class RnaTranscription : Exercise
4+
{
5+
}
6+
}

0 commit comments

Comments
 (0)