Skip to content

Commit 6dc2f69

Browse files
simple-cipher: add test for random keys
1 parent 4c90d91 commit 6dc2f69

File tree

5 files changed

+32
-4
lines changed

5 files changed

+32
-4
lines changed

exercises/practice/crypto-square/CryptoSquareTests.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,10 @@ public void Fifty_four_character_plaintext_results_in_7_chunks_the_last_two_with
4747
{
4848
Assert.Equal("imtgdvs fearwer mayoogo anouuio ntnnlvt wttddes aohghn sseoau ", CryptoSquare.Ciphertext("If man was meant to stay on the ground, god would have given us roots."));
4949
}
50+
51+
[Fact(Skip = "Remove this Skip property to run this test")]
52+
public void Fifty_four_character_plaintext_results_in_8_chunks_the_last_two_with_trailing_spaces()
53+
{
54+
Assert.Equal("imtgdvs fearwer mayoogo anouuio ntnnlvt wttddes aohghn sseoau ", CryptoSquare.Ciphertext("If man was meant to stay on the ground, god would have given us roots."));
55+
}
5056
}

exercises/practice/game-of-life/GameOfLifeTests.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
using Xunit;
2-
31
public class GameOfLifeTests
42
{
53
[Fact]

exercises/practice/largest-series-product/LargestSeriesProductTests.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,18 @@ public void Rejects_span_longer_than_string_length()
6060
Assert.Throws<ArgumentException>(() => LargestSeriesProduct.GetLargestProduct("123", 4));
6161
}
6262

63+
[Fact(Skip = "Remove this Skip property to run this test")]
64+
public void Rejects_span_longer_than_string_length()
65+
{
66+
Assert.Throws<ArgumentException>(() => LargestSeriesProduct.GetLargestProduct("123", 4));
67+
}
68+
69+
[Fact(Skip = "Remove this Skip property to run this test")]
70+
public void Rejects_empty_string_and_nonzero_span()
71+
{
72+
Assert.Throws<ArgumentException>(() => LargestSeriesProduct.GetLargestProduct("", 1));
73+
}
74+
6375
[Fact(Skip = "Remove this Skip property to run this test")]
6476
public void Rejects_empty_string_and_nonzero_span()
6577
{

exercises/practice/simple-cipher/.meta/Generator.tpl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ end}}
1616
end
1717
end}}
1818

19-
using Xunit;
20-
2119
public class {{ testClass }}
2220
{
2321
{{- for test in tests }}
@@ -31,6 +29,13 @@ public class {{ testClass }}
3129
Assert.Equal({{- test.expected | string.literal }}, sut.Decode({{ test | decode_arg }}));
3230
{{- else if test.property == "key" }}
3331
Assert.Matches({{- test.expected.match | string.literal }}, sut.Key);
32+
}
33+
34+
[Fact(Skip = "Remove this Skip property to run this test")]
35+
public void Random_key_cipher_key_is_random()
36+
{
37+
var keys = Enumerable.Range(0, 1000).Select(_ => new SimpleCipher().Key).ToArray();
38+
Assert.InRange(keys.Distinct().Count(), keys.Length - 100, keys.Length);
3439
{{ end -}}
3540
}
3641
{{ end -}}

exercises/practice/simple-cipher/SimpleCipherTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ public void Random_key_cipher_key_is_made_only_of_lowercase_letters()
2828
Assert.Matches("^[a-z]+$", sut.Key);
2929
}
3030

31+
[Fact(Skip = "Remove this Skip property to run this test")]
32+
public void Random_key_cipher_key_is_random()
33+
{
34+
var keys = Enumerable.Range(0, 1000).Select(_ => new SimpleCipher().Key).ToArray();
35+
Assert.InRange(keys.Distinct().Count(), keys.Length - 100, keys.Length);
36+
}
37+
3138
[Fact(Skip = "Remove this Skip property to run this test")]
3239
public void Substitution_cipher_can_encode()
3340
{

0 commit comments

Comments
 (0)