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
85 changes: 23 additions & 62 deletions exercises/crypto-square/CryptoSquareTest.cs
Original file line number Diff line number Diff line change
@@ -1,98 +1,59 @@
// This file was auto-generated based on version 2.0.0 of the canonical data.
// This file was auto-generated based on version 3.1.0 of the canonical data.

using Xunit;

public class CryptoSquareTest
{
[Fact]
public void Lowercase()
{
var plaintext = "Hello";
var expected = "hello";
Assert.Equal(expected, CryptoSquare.NormalizedPlaintext(plaintext));
}

[Fact(Skip = "Remove to run test")]
public void Remove_spaces()
{
var plaintext = "Hi there";
var expected = "hithere";
Assert.Equal(expected, CryptoSquare.NormalizedPlaintext(plaintext));
}

[Fact(Skip = "Remove to run test")]
public void Remove_punctuation()
{
var plaintext = "@1, 2%, 3 Go!";
var expected = "123go";
Assert.Equal(expected, CryptoSquare.NormalizedPlaintext(plaintext));
}

[Fact(Skip = "Remove to run test")]
public void Empty_plaintext_results_in_an_empty_rectangle()
public void Empty_plaintext_results_in_an_empty_ciphertext()
{
var plaintext = "";
Assert.Empty(CryptoSquare.PlaintextSegments(plaintext));
}

[Fact(Skip = "Remove to run test")]
public void Number_4_character_plaintext_results_in_an_2x2_rectangle()
{
var plaintext = "Ab Cd";
var expected = new[] { "ab", "cd" };
Assert.Equal(expected, CryptoSquare.PlaintextSegments(plaintext));
}

[Fact(Skip = "Remove to run test")]
public void Number_9_character_plaintext_results_in_an_3x3_rectangle()
{
var plaintext = "This is fun!";
var expected = new[] { "thi", "sis", "fun" };
Assert.Equal(expected, CryptoSquare.PlaintextSegments(plaintext));
var expected = "";
Assert.Equal(expected, CryptoSquare.Ciphertext(plaintext));
}

[Fact(Skip = "Remove to run test")]
public void Number_54_character_plaintext_results_in_an_8x7_rectangle()
public void Lowercase()
{
var plaintext = "If man was meant to stay on the ground, god would have given us roots.";
var expected = new[] { "ifmanwas", "meanttos", "tayonthe", "groundgo", "dwouldha", "vegivenu", "sroots" };
Assert.Equal(expected, CryptoSquare.PlaintextSegments(plaintext));
var plaintext = "A";
var expected = "a";
Assert.Equal(expected, CryptoSquare.Ciphertext(plaintext));
}

[Fact(Skip = "Remove to run test")]
public void Empty_plaintext_results_in_an_empty_encode()
public void Remove_spaces()
{
var plaintext = "";
var expected = "";
Assert.Equal(expected, CryptoSquare.Encoded(plaintext));
var plaintext = " b ";
var expected = "b";
Assert.Equal(expected, CryptoSquare.Ciphertext(plaintext));
}

[Fact(Skip = "Remove to run test")]
public void Non_empty_plaintext_results_in_the_combined_plaintext_segments()
public void Remove_punctuation()
{
var plaintext = "If man was meant to stay on the ground, god would have given us roots.";
var expected = "imtgdvsfearwermayoogoanouuiontnnlvtwttddesaohghnsseoau";
Assert.Equal(expected, CryptoSquare.Encoded(plaintext));
var plaintext = "@1,%!";
var expected = "1";
Assert.Equal(expected, CryptoSquare.Ciphertext(plaintext));
}

[Fact(Skip = "Remove to run test")]
public void Empty_plaintext_results_in_an_empty_ciphertext()
public void Number_9_character_plaintext_results_in_3_chunks_of_3_characters()
{
var plaintext = "";
var expected = "";
var plaintext = "This is fun!";
var expected = "tsf hiu isn";
Assert.Equal(expected, CryptoSquare.Ciphertext(plaintext));
}

[Fact(Skip = "Remove to run test")]
public void Number_9_character_plaintext_results_in_3_chunks_of_3_characters()
public void Number_8_character_plaintext_results_in_3_chunks_the_last_one_with_a_trailing_space()
{
var plaintext = "This is fun!";
var expected = "tsf hiu isn";
var plaintext = "Chill out.";
var expected = "clu hlt io ";
Assert.Equal(expected, CryptoSquare.Ciphertext(plaintext));
}

[Fact(Skip = "Remove to run test")]
public void Number_54_character_plaintext_results_in_7_chunks_the_last_two_padded_with_spaces()
public void Number_54_character_plaintext_results_in_7_chunks_the_last_two_with_trailing_spaces()
{
var plaintext = "If man was meant to stay on the ground, god would have given us roots.";
var expected = "imtgdvs fearwer mayoogo anouuio ntnnlvt wttddes aohghn sseoau ";
Expand Down
4 changes: 1 addition & 3 deletions exercises/food-chain/Example.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ public static class FoodChain
"I don't know why she swallowed the fly. Perhaps she'll die."
};

public static string Verse(int number) => $"{VerseBegin(number)}\n{VerseEnd(number)}";

public static string Verse(int begin, int end) => string.Join("\n\n", Enumerable.Range(begin, end - begin + 1).Select(i => Verse(i)));
public static string Recite(int startVerse, int endVerse) => string.Join("\n\n", Enumerable.Range(startVerse, endVerse - startVerse + 1).Select(i => $"{VerseBegin(i)}\n{VerseEnd(i)}"));

private static string VerseBegin(int number)
{
Expand Down
7 changes: 1 addition & 6 deletions exercises/food-chain/FoodChain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@

public static class FoodChain
{
public static string Verse(int number)
{
throw new NotImplementedException("You need to implement this function.");
}

public static string Verse(int begin, int end)
public static string Recite(int startVerse, int endVerse)
{
throw new NotImplementedException("You need to implement this function.");
}
Expand Down
22 changes: 11 additions & 11 deletions exercises/food-chain/FoodChainTest.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.0 of the canonical data.
// This file was auto-generated based on version 2.0.0 of the canonical data.

using Xunit;

Expand All @@ -10,7 +10,7 @@ public void Fly()
var expected =
"I know an old lady who swallowed a fly.\n" +
"I don't know why she swallowed the fly. Perhaps she'll die.";
Assert.Equal(expected, FoodChain.Verse(1));
Assert.Equal(expected, FoodChain.Recite(1, 1));
}

[Fact(Skip = "Remove to run test")]
Expand All @@ -21,7 +21,7 @@ public void Spider()
"It wriggled and jiggled and tickled inside her.\n" +
"She swallowed the spider to catch the fly.\n" +
"I don't know why she swallowed the fly. Perhaps she'll die.";
Assert.Equal(expected, FoodChain.Verse(2));
Assert.Equal(expected, FoodChain.Recite(2, 2));
}

[Fact(Skip = "Remove to run test")]
Expand All @@ -33,7 +33,7 @@ public void Bird()
"She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n" +
"She swallowed the spider to catch the fly.\n" +
"I don't know why she swallowed the fly. Perhaps she'll die.";
Assert.Equal(expected, FoodChain.Verse(3));
Assert.Equal(expected, FoodChain.Recite(3, 3));
}

[Fact(Skip = "Remove to run test")]
Expand All @@ -46,7 +46,7 @@ public void Cat()
"She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n" +
"She swallowed the spider to catch the fly.\n" +
"I don't know why she swallowed the fly. Perhaps she'll die.";
Assert.Equal(expected, FoodChain.Verse(4));
Assert.Equal(expected, FoodChain.Recite(4, 4));
}

[Fact(Skip = "Remove to run test")]
Expand All @@ -60,7 +60,7 @@ public void Dog()
"She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n" +
"She swallowed the spider to catch the fly.\n" +
"I don't know why she swallowed the fly. Perhaps she'll die.";
Assert.Equal(expected, FoodChain.Verse(5));
Assert.Equal(expected, FoodChain.Recite(5, 5));
}

[Fact(Skip = "Remove to run test")]
Expand All @@ -75,7 +75,7 @@ public void Goat()
"She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n" +
"She swallowed the spider to catch the fly.\n" +
"I don't know why she swallowed the fly. Perhaps she'll die.";
Assert.Equal(expected, FoodChain.Verse(6));
Assert.Equal(expected, FoodChain.Recite(6, 6));
}

[Fact(Skip = "Remove to run test")]
Expand All @@ -91,7 +91,7 @@ public void Cow()
"She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n" +
"She swallowed the spider to catch the fly.\n" +
"I don't know why she swallowed the fly. Perhaps she'll die.";
Assert.Equal(expected, FoodChain.Verse(7));
Assert.Equal(expected, FoodChain.Recite(7, 7));
}

[Fact(Skip = "Remove to run test")]
Expand All @@ -100,7 +100,7 @@ public void Horse()
var expected =
"I know an old lady who swallowed a horse.\n" +
"She's dead, of course!";
Assert.Equal(expected, FoodChain.Verse(8));
Assert.Equal(expected, FoodChain.Recite(8, 8));
}

[Fact(Skip = "Remove to run test")]
Expand All @@ -120,7 +120,7 @@ public void Multiple_verses()
"She swallowed the bird to catch the spider that wriggled and jiggled and tickled inside her.\n" +
"She swallowed the spider to catch the fly.\n" +
"I don't know why she swallowed the fly. Perhaps she'll die.";
Assert.Equal(expected, FoodChain.Verse(1, 3));
Assert.Equal(expected, FoodChain.Recite(1, 3));
}

[Fact(Skip = "Remove to run test")]
Expand Down Expand Up @@ -177,6 +177,6 @@ public void Full_song()
"\n" +
"I know an old lady who swallowed a horse.\n" +
"She's dead, of course!";
Assert.Equal(expected, FoodChain.Verse(1, 8));
Assert.Equal(expected, FoodChain.Recite(1, 8));
}
}
6 changes: 3 additions & 3 deletions exercises/hamming/HammingTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was auto-generated based on version 2.0.0 of the canonical data.
// This file was auto-generated based on version 2.0.1 of the canonical data.

using Xunit;
using System;
Expand Down Expand Up @@ -56,13 +56,13 @@ public void Small_distance_in_long_strands()
[Fact(Skip = "Remove to run test")]
public void Non_unique_character_in_first_strand()
{
Assert.Equal(1, Hamming.Distance("AGA", "AGG"));
Assert.Equal(1, Hamming.Distance("AAG", "AAA"));
}

[Fact(Skip = "Remove to run test")]
public void Non_unique_character_in_second_strand()
{
Assert.Equal(1, Hamming.Distance("AGG", "AGA"));
Assert.Equal(1, Hamming.Distance("AAA", "AAG"));
}

[Fact(Skip = "Remove to run test")]
Expand Down
8 changes: 4 additions & 4 deletions exercises/house/Example.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ public static class House
""
};

public static string Verses(int first, int last)
public static string Recite(int startVerse, int endVerse)
{
var numberOfVerses = last - first + 1;
return string.Join("\n\n", Enumerable.Range(first, numberOfVerses).Select(Verse));
var numberOfVerses = endVerse - startVerse + 1;
return string.Join("\n\n", Enumerable.Range(startVerse, numberOfVerses).Select(Verse));
}

public static string Verse(int number)
private static string Verse(int number)
{
return string.Join("\n", Enumerable.Range(1, number).Reverse().Select(index => Line(number, index)));
}
Expand Down
7 changes: 1 addition & 6 deletions exercises/house/House.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@

public static class House
{
public static string Verse(int number)
{
throw new NotImplementedException("You need to implement this function.");
}

public static string Verses(int first, int last)
public static string Recite(int startVerse, int endVerse)
{
throw new NotImplementedException("You need to implement this function.");
}
Expand Down
Loading