Sha256: f92240a547372d702fb6397626fb91407bc6a6e4295c0788ee3dd37fb9031111

Contents?: true

Size: 1.26 KB

Versions: 86

Compression:

Stored size: 1.26 KB

Contents

using System;
using Generators.Input;
using Generators.Output;

namespace Generators.Exercises
{
    public class OcrNumbers : GeneratorExercise
    {
        protected override void UpdateCanonicalData(CanonicalData canonicalData)
        {
            foreach (var canonicalDataCase in canonicalData.Cases)
            {
                canonicalDataCase.ExceptionThrown = (canonicalDataCase.Expected is long && canonicalDataCase.Expected <= 0) ? typeof(ArgumentException) : null;
                canonicalDataCase.Properties["input"] = ToDigitStringRepresentation(canonicalDataCase.Properties["input"]);
                canonicalDataCase.Expected = canonicalDataCase.Expected.ToString();
                canonicalDataCase.UseVariableForTested = true;
                canonicalDataCase.UseVariablesForInput = true;
            }
        }
       
        private UnescapedValue ToDigitStringRepresentation(string[] input)
        {
            const string template = @" {% for item in {{input}} %}{% if forloop.first == true %}""{{item}}"" + ""\n"" +{% continue %}{% endif %}
             ""{{item}}""{% if forloop.last == false %} + ""\n"" +{% endif %}{% endfor %}";

            return new UnescapedValue(TemplateRenderer.RenderInline(template, new { input }));
        }
    }
}

Version data entries

86 entries across 86 versions & 1 rubygems

Version Path
trackler-2.2.1.90 tracks/csharp/generators/Exercises/OcrNumbers.cs
trackler-2.2.1.89 tracks/csharp/generators/Exercises/OcrNumbers.cs
trackler-2.2.1.88 tracks/csharp/generators/Exercises/OcrNumbers.cs
trackler-2.2.1.87 tracks/csharp/generators/Exercises/OcrNumbers.cs
trackler-2.2.1.86 tracks/csharp/generators/Exercises/OcrNumbers.cs
trackler-2.2.1.85 tracks/csharp/generators/Exercises/OcrNumbers.cs
trackler-2.2.1.84 tracks/csharp/generators/Exercises/OcrNumbers.cs
trackler-2.2.1.83 tracks/csharp/generators/Exercises/OcrNumbers.cs
trackler-2.2.1.82 tracks/csharp/generators/Exercises/OcrNumbers.cs
trackler-2.2.1.81 tracks/csharp/generators/Exercises/OcrNumbers.cs
trackler-2.2.1.80 tracks/csharp/generators/Exercises/OcrNumbers.cs
trackler-2.2.1.79 tracks/csharp/generators/Exercises/OcrNumbers.cs
trackler-2.2.1.78 tracks/csharp/generators/Exercises/OcrNumbers.cs
trackler-2.2.1.77 tracks/csharp/generators/Exercises/OcrNumbers.cs
trackler-2.2.1.76 tracks/csharp/generators/Exercises/OcrNumbers.cs
trackler-2.2.1.75 tracks/csharp/generators/Exercises/OcrNumbers.cs
trackler-2.2.1.74 tracks/csharp/generators/Exercises/OcrNumbers.cs
trackler-2.2.1.73 tracks/csharp/generators/Exercises/OcrNumbers.cs
trackler-2.2.1.72 tracks/csharp/generators/Exercises/OcrNumbers.cs
trackler-2.2.1.71 tracks/csharp/generators/Exercises/OcrNumbers.cs