Sha256: 25347e619aa6864978ec49bc6735560d234189a2621ab8a01d826fd2cab268c9
Contents?: true
Size: 1.46 KB
Versions: 49
Compression:
Stored size: 1.46 KB
Contents
using Generators.Input; using Generators.Output; namespace Generators.Exercises { public class RunLengthEncoding : Exercise { protected override void UpdateCanonicalData(CanonicalData canonicalData) { foreach (var canonicalDataCase in canonicalData.Cases) { // Prefix the test name with encode/decode because both functions are tested with the same cases canonicalDataCase.Description = $"{canonicalDataCase.Property} {canonicalDataCase.Description}"; } } protected override string RenderTestMethodBodyAssert(TestMethodBody testMethodBody) { if (testMethodBody.CanonicalDataCase.Property == "consistency") { return RenderConsistencyToAssert(testMethodBody); } return base.RenderTestMethodBodyAssert(testMethodBody); } private static string RenderConsistencyToAssert(TestMethodBody testMethodBody) { const string template = @"Assert.Equal(""{{ExpectedOutput}}"", {{ExerciseName}}.Decode({{ExerciseName}}.Encode(""{{ExpectedOutput}}"")));"; var templateParameters = new { ExpectedOutput = testMethodBody.CanonicalDataCase.Expected, ExerciseName = testMethodBody.CanonicalData.Exercise.ToTestedClassName() }; return TemplateRenderer.RenderInline(template, templateParameters); } } }
Version data entries
49 entries across 49 versions & 1 rubygems