Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test generator for rna transcription exercise #353

Merged
merged 3 commits into from
Aug 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion exercises/rail-fence-cipher/RailFenceCipherTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was auto-generated based on version 1.0.1 of the canonical data.
// This file was auto-generated based on version 1.0.1 of the canonical data.

using Xunit;

Expand Down
9 changes: 7 additions & 2 deletions exercises/rna-transcription/Example.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
using System.Collections.Generic;
using System.Linq;

public class Complement
public static class RnaTranscription
{
private static readonly Dictionary<char, char> DnaToRna = new Dictionary<char, char>
{
{ 'G', 'C' }, { 'C', 'G' }, { 'T', 'A' }, { 'A', 'U' }
};

public static string OfDna(string nucleotide)
public static string ToRna(string nucleotide)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The build fails because this (example) class' name has not been renamed to RnaTranscription.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I fixed that and updated the PR.

{
if (nucleotide.Any(x => !DnaToRna.ContainsKey(x)))
{
return null;
}

return string.Concat(nucleotide.Select(x => DnaToRna[x]));
}
}
4 changes: 2 additions & 2 deletions exercises/rna-transcription/RnaTranscription.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System;

public static class Complement
public static class RnaTranscription
{
public static string OfDna(string nucleotide)
public static string ToRna(string nucleotide)
{
throw new NotImplementedException("You need to implement this function.");
}
Expand Down
32 changes: 26 additions & 6 deletions exercises/rna-transcription/RnaTranscriptionTest.cs
Original file line number Diff line number Diff line change
@@ -1,34 +1,54 @@
// This file was auto-generated based on version 1.0.1 of the canonical data.

using Xunit;

public class ComplementTest
public class RnaTranscriptionTest
{
[Fact]
public void Rna_complement_of_cytosine_is_guanine()
{
Assert.Equal("G", Complement.OfDna("C"));
Assert.Equal("G", RnaTranscription.ToRna("C"));
}

[Fact(Skip = "Remove to run test")]
public void Rna_complement_of_guanine_is_cytosine()
{
Assert.Equal("C", Complement.OfDna("G"));
Assert.Equal("C", RnaTranscription.ToRna("G"));
}

[Fact(Skip = "Remove to run test")]
public void Rna_complement_of_thymine_is_adenine()
{
Assert.Equal("A", Complement.OfDna("T"));
Assert.Equal("A", RnaTranscription.ToRna("T"));
}

[Fact(Skip = "Remove to run test")]
public void Rna_complement_of_adenine_is_uracil()
{
Assert.Equal("U", Complement.OfDna("A"));
Assert.Equal("U", RnaTranscription.ToRna("A"));
}

[Fact(Skip = "Remove to run test")]
public void Rna_complement()
{
Assert.Equal("UGCACCAGAAUU", Complement.OfDna("ACGTGGTCTTAA"));
Assert.Equal("UGCACCAGAAUU", RnaTranscription.ToRna("ACGTGGTCTTAA"));
}

[Fact(Skip = "Remove to run test")]
public void Correctly_handles_invalid_input_rna_instead_of_dna_()
{
Assert.Null(RnaTranscription.ToRna("U"));
}

[Fact(Skip = "Remove to run test")]
public void Correctly_handles_completely_invalid_dna_input()
{
Assert.Null(RnaTranscription.ToRna("XXX"));
}

[Fact(Skip = "Remove to run test")]
public void Correctly_handles_partially_invalid_dna_input()
{
Assert.Null(RnaTranscription.ToRna("ACGTXXXCTTAA"));
}
}
2 changes: 1 addition & 1 deletion exercises/two-fer/TwoFerTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was auto-generated based on version 1.1.0 of the canonical data.
// This file was auto-generated based on version 1.1.0 of the canonical data.

using Xunit;

Expand Down
6 changes: 6 additions & 0 deletions generators/Exercises/RnaTranscription.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Generators.Exercises
{
public class RnaTranscription : Exercise
{
}
}