Skip to content
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

Merged
merged 5 commits into from Oct 12, 2018
Merged

add Affine cipher #688

merged 5 commits into from Oct 12, 2018

Conversation

davidelettieri
Copy link
Contributor

add affine cipher exercise, info for config file is taken from ruby project

Copy link
Member

@ErikSchierboom ErikSchierboom left a 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.

config.json Outdated Show resolved Hide resolved
config.json Outdated Show resolved Hide resolved
exercises/affine-cipher/AffineCipher.cs Outdated Show resolved Hide resolved
exercises/affine-cipher/AffineCipher.cs Outdated Show resolved Hide resolved
exercises/affine-cipher/AffineCipher.cs Outdated Show resolved Hide resolved
exercises/affine-cipher/Example.cs Outdated Show resolved Hide resolved
exercises/affine-cipher/Example.cs Outdated Show resolved Hide resolved
exercises/affine-cipher/Example.cs Outdated Show resolved Hide resolved
exercises/affine-cipher/README.md Outdated Show resolved Hide resolved

namespace Exercism.CSharp.Exercises.Generators
{
public class AffineCipher : GeneratorExercise
Copy link
Member

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.

Copy link
Contributor Author

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?

@ErikSchierboom
Copy link
Member

This is looking great! I've solved the solution conflict. When the CI is green, I'll merge!

@ErikSchierboom ErikSchierboom merged commit 7668e9c into exercism:master Oct 12, 2018
@ErikSchierboom
Copy link
Member

Merged, thanks a lot! 🎉

@davidelettieri
Copy link
Contributor Author

Thanks to you :)

ErikSchierboom added a commit to ErikSchierboom/csharp that referenced this pull request Jan 15, 2021
Extract space-age Concepts

Co-authored-by: Erik Schierboom <erik_schierboom@hotmail.com>
ErikSchierboom added a commit to ErikSchierboom/csharp that referenced this pull request Jan 21, 2021
Extract space-age Concepts

Co-authored-by: Erik Schierboom <erik_schierboom@hotmail.com>
ErikSchierboom added a commit to ErikSchierboom/csharp that referenced this pull request Jan 26, 2021
Extract space-age Concepts

Co-authored-by: Erik Schierboom <erik_schierboom@hotmail.com>
ErikSchierboom added a commit to ErikSchierboom/csharp that referenced this pull request Jan 27, 2021
Extract space-age Concepts

Co-authored-by: Erik Schierboom <erik_schierboom@hotmail.com>
ErikSchierboom added a commit to ErikSchierboom/csharp that referenced this pull request Jan 28, 2021
Extract space-age Concepts

Co-authored-by: Erik Schierboom <erik_schierboom@hotmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants