exercism / csharp

Exercism exercises in C#.
https://exercism.org/tracks/csharp
MIT License
347 stars 346 forks source link

Add Tournament Test Generator #422

Closed jpreese closed 7 years ago

jpreese commented 7 years ago

This issue is part of an overall initiative to complete #195.

The documentation on how to add generators can be found here. If you get stuck or have any questions about adding this generator, please do not hesitate to reach out!

GKotfis commented 7 years ago

unless there is not limit I'll deal with it :)

ErikSchierboom commented 7 years ago

There is no limit! Go for it! :)

GKotfis commented 7 years ago

Btw this generator could use some helper method like existing "RunTally" that convert IO Stream to string. I don't see such option now. So one solution will be to add this logic for every test or maybe better - extend generator Output API to have option to write custom methods, code in test class. What do you think?

ErikSchierboom commented 7 years ago

I agree, and in principle this is already supported as the TestClass class has a property Methods (note that I explicitly named it Methods, not TestMethods, to which you could then add the utility method. At the moment, the CreateTestClass function creates the TestClass instance. We can do several things:

  1. Make CreateTestClass virtual so that you can add additional methods.
  2. Add an additional virtual method to the Exercise class, named something like RenderAdditionalMethods, that returns a string[] and combine that with the output of RenderTestMethods.

My preference goes to option 2, what about you? And @robkeim and @jpreese ?

robkeim commented 7 years ago

@ErikSchierboom option 2 would also be my preferred solution as I think it's more explicit.

jpreese commented 7 years ago

If I understand the problem scope correctly, in the sense that we want the ability to add helper methods to the generated test suite, Option 2 seems like the best approach.

We can take the string array and just append it onto the end of the collection of tests so that the helpers always appear at the bottom.

GKotfis commented 7 years ago

Let's create separate issue for that.

ErikSchierboom commented 7 years ago

@GKotfis Thanks to @GKotfis, there is now support for additional methods (see #454).

ErikSchierboom commented 7 years ago

Closed by #457