File tree Expand file tree Collapse file tree 3 files changed +39
-66
lines changed
exercises/practice/simple-cipher
generators.deprecated/Exercises/Generators Expand file tree Collapse file tree 3 files changed +39
-66
lines changed Original file line number Diff line number Diff line change 1+ using Xunit;
2+
3+ { {func decode_arg} }
4+ { {if $0.input.ciphertext == " cipher.encode" } }
5+ sut.Encode({ {$0.input.plaintext | string.literal } })
6+ { {else if $0.input.ciphertext == " cipher.key.substring(0, expected.length)" } }
7+ sut.Key.Substring(0, 10)
8+ { {else } }
9+ { {$0.input.ciphertext | string.literal } }
10+ { {end} }
11+ { {end} }
12+
13+ { {func expected_value} }
14+ { {if $0 == " cipher.key.substring(0, plaintext.length)" } }
15+ sut.Key.Substring(0, 10)
16+ { {else } }
17+ { { $0 | string.literal } }
18+ { {end} }
19+ { {end} }
20+
21+ public class SimpleCipherTests
22+ {
23+ {{for testCase in testCases} }
24+ [Fact{ {if ! for.first} }(Skip = "Remove this Skip property to run this test"){ {end} }]
25+ public void { {testCase.testMethodName} }()
26+ {
27+ var sut = new SimpleCipher({{if testCase.input.key} }{ {testCase.input.key | string.literal } }{ {end} });
28+ { {if testCase.property == " encode" } }
29+ Assert.Equal({ {testCase.expected | expected_value} }, sut.Encode({ {testCase.input.plaintext | string.literal } }));
30+ { {else if testCase.property == " decode" } }
31+ Assert.Equal({ {testCase.expected | string.literal } }, sut.Decode({ {testCase | decode_arg} }));
32+ { {else if testCase.property == " key" } }
33+ Assert.Matches({ {testCase.expected.match | string.literal } }, sut.Key);
34+ { {end} }
35+ }
36+ { {end} }
37+ }
Original file line number Diff line number Diff line change 1- using System ;
21using Xunit ;
32
43public class SimpleCipherTests
@@ -18,7 +17,7 @@ public void Random_key_cipher_can_decode()
1817 }
1918
2019 [ Fact ( Skip = "Remove this Skip property to run this test" ) ]
21- public void Random_key_cipher_is_reversible_i_e_if_you_apply_decode_in_a_encoded_result_you_must_see_the_same_plaintext_encode_parameter_as_a_result_of_the_decode_method ( )
20+ public void Random_key_cipher_is_reversible_ie_if_you_apply_decode_in_a_encoded_result_you_must_see_the_same_plaintext_encode_parameter_as_a_result_of_the_decode_method ( )
2221 {
2322 var sut = new SimpleCipher ( ) ;
2423 Assert . Equal ( "abcdefghij" , sut . Decode ( sut . Encode ( "abcdefghij" ) ) ) ;
@@ -46,7 +45,7 @@ public void Substitution_cipher_can_decode()
4645 }
4746
4847 [ Fact ( Skip = "Remove this Skip property to run this test" ) ]
49- public void Substitution_cipher_is_reversible_i_e_if_you_apply_decode_in_a_encoded_result_you_must_see_the_same_plaintext_encode_parameter_as_a_result_of_the_decode_method ( )
48+ public void Substitution_cipher_is_reversible_ie_if_you_apply_decode_in_a_encoded_result_you_must_see_the_same_plaintext_encode_parameter_as_a_result_of_the_decode_method ( )
5049 {
5150 var sut = new SimpleCipher ( "abcdefghij" ) ;
5251 Assert . Equal ( "abcdefghij" , sut . Decode ( sut . Encode ( "abcdefghij" ) ) ) ;
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments