Skip to content
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
3 changes: 2 additions & 1 deletion exercises/phone-number/Example.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Linq;
using System.Text.RegularExpressions;

Expand All @@ -17,7 +18,7 @@ public static string Clean(string phoneNumber)
}
else
{
return null;
throw new ArgumentException("invalid phone number");
}
}
}
15 changes: 8 additions & 7 deletions exercises/phone-number/PhoneNumberTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// This file was auto-generated based on version 1.2.0 of the canonical data.

using Xunit;
using System;

public class PhoneNumberTest
{
Expand Down Expand Up @@ -29,14 +30,14 @@ public void Cleans_numbers_with_multiple_spaces()
public void Invalid_when_9_digits()
{
var phrase = "123456789";
Assert.Null(PhoneNumber.Clean(phrase));
Assert.Throws<ArgumentException>(() => PhoneNumber.Clean(phrase));
}

[Fact(Skip = "Remove to run test")]
public void Invalid_when_11_digits_does_not_start_with_a_1()
{
var phrase = "22234567890";
Assert.Null(PhoneNumber.Clean(phrase));
Assert.Throws<ArgumentException>(() => PhoneNumber.Clean(phrase));
}

[Fact(Skip = "Remove to run test")]
Expand All @@ -57,34 +58,34 @@ public void Valid_when_11_digits_and_starting_with_1_even_with_punctuation()
public void Invalid_when_more_than_11_digits()
{
var phrase = "321234567890";
Assert.Null(PhoneNumber.Clean(phrase));
Assert.Throws<ArgumentException>(() => PhoneNumber.Clean(phrase));
}

[Fact(Skip = "Remove to run test")]
public void Invalid_with_letters()
{
var phrase = "123-abc-7890";
Assert.Null(PhoneNumber.Clean(phrase));
Assert.Throws<ArgumentException>(() => PhoneNumber.Clean(phrase));
}

[Fact(Skip = "Remove to run test")]
public void Invalid_with_punctuations()
{
var phrase = "123-@:!-7890";
Assert.Null(PhoneNumber.Clean(phrase));
Assert.Throws<ArgumentException>(() => PhoneNumber.Clean(phrase));
}

[Fact(Skip = "Remove to run test")]
public void Invalid_if_area_code_does_not_start_with_2_9()
{
var phrase = "(123) 456-7890";
Assert.Null(PhoneNumber.Clean(phrase));
Assert.Throws<ArgumentException>(() => PhoneNumber.Clean(phrase));
}

[Fact(Skip = "Remove to run test")]
public void Invalid_if_exchange_code_does_not_start_with_2_9()
{
var phrase = "(223) 056-7890";
Assert.Null(PhoneNumber.Clean(phrase));
Assert.Throws<ArgumentException>(() => PhoneNumber.Clean(phrase));
}
}
3 changes: 2 additions & 1 deletion exercises/rna-transcription/Example.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;

Expand All @@ -12,7 +13,7 @@ public static string ToRna(string nucleotide)
{
if (nucleotide.Any(x => !DnaToRna.ContainsKey(x)))
{
return null;
throw new ArgumentException("invalid nucleotide");
}

return string.Concat(nucleotide.Select(x => DnaToRna[x]));
Expand Down
7 changes: 4 additions & 3 deletions exercises/rna-transcription/RnaTranscriptionTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// This file was auto-generated based on version 1.0.1 of the canonical data.

using Xunit;
using System;

public class RnaTranscriptionTest
{
Expand Down Expand Up @@ -37,18 +38,18 @@ public void Rna_complement()
[Fact(Skip = "Remove to run test")]
public void Correctly_handles_invalid_input_rna_instead_of_dna_()
{
Assert.Null(RnaTranscription.ToRna("U"));
Assert.Throws<ArgumentException>(() => RnaTranscription.ToRna("U"));
}

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

[Fact(Skip = "Remove to run test")]
public void Correctly_handles_partially_invalid_dna_input()
{
Assert.Null(RnaTranscription.ToRna("ACGTXXXCTTAA"));
Assert.Throws<ArgumentException>(() => RnaTranscription.ToRna("ACGTXXXCTTAA"));
}
}
4 changes: 3 additions & 1 deletion generators/Exercises/PhoneNumber.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Generators.Input;
using System;
using Generators.Input;

namespace Generators.Exercises
{
Expand All @@ -9,6 +10,7 @@ protected override void UpdateCanonicalData(CanonicalData canonicalData)
foreach (var canonicalDataCase in CanonicalData.Cases)
{
canonicalDataCase.UseVariablesForInput = true;
canonicalDataCase.ExceptionThrown = canonicalDataCase.Expected is null ? typeof(ArgumentException) : null;
}
}
}
Expand Down
12 changes: 11 additions & 1 deletion generators/Exercises/RnaTranscription.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
namespace Generators.Exercises
using System;
using Generators.Input;

namespace Generators.Exercises
{
public class RnaTranscription : Exercise
{
protected override void UpdateCanonicalData(CanonicalData canonicalData)
{
foreach (var canonicalDataCase in CanonicalData.Cases)
{
canonicalDataCase.ExceptionThrown = canonicalDataCase.Expected is null ? typeof(ArgumentException) : null;
}
}
}
}