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 Affine cipher #688
add Affine cipher #688
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much for doing this! It is already looking quite good! I've requested some small changes, and suggested a simplification of the generator code.
|
||
namespace Exercism.CSharp.Exercises.Generators | ||
{ | ||
public class AffineCipher : GeneratorExercise |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is quite a bit of customization going on here, and I think we can simplify things quite a bit. Let me explain!
Looking at the canonical data, the input data is straightforward, except for the "key"
property, which is a nested property. You can work around this using the following code in the UpdateTestMethod
method:
testMethod.Input["a"] = testMethod.Input["key"]["a"];
testMethod.Input["b"] = testMethod.Input["key"]["b"];
testMethod.InputParameters = new[] { "phrase", "a", "b" };
The second bit is dealing with exception, which is also easy to fix:
if (!(testMethod.Expected is string))
testMethod.ExceptionThrown = typeof(ArgumentException);
With just these 5 lines of code, the generate becomes a lot simpler and still generates a nice test file. The only change you have to make in your example and stub files is make them use a static class with static methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generator is considerably better, we're missing check on exception message. Is there a simple way to do it?
This is looking great! I've solved the solution conflict. When the CI is green, I'll merge! |
Merged, thanks a lot! 🎉 |
Thanks to you :) |
Extract space-age Concepts Co-authored-by: Erik Schierboom <erik_schierboom@hotmail.com>
Extract space-age Concepts Co-authored-by: Erik Schierboom <erik_schierboom@hotmail.com>
Extract space-age Concepts Co-authored-by: Erik Schierboom <erik_schierboom@hotmail.com>
Extract space-age Concepts Co-authored-by: Erik Schierboom <erik_schierboom@hotmail.com>
Extract space-age Concepts Co-authored-by: Erik Schierboom <erik_schierboom@hotmail.com>
add affine cipher exercise, info for config file is taken from ruby project