Sha256: 7fcdca727c9d0b12fe9b1e7c19c39eefedc53dee79524f9be1e53841340bf28b

Contents?: true

Size: 1.91 KB

Versions: 86

Compression:

Stored size: 1.91 KB

Contents

using Generators.Input;
using Generators.Output;

namespace Generators.Exercises
{
    public class TwoBucket : GeneratorExercise
    {
        protected override void UpdateCanonicalData(CanonicalData canonicalData)
        {
            foreach (var canonicalDataCase in canonicalData.Cases)
            {
                canonicalDataCase.TestedMethodType = TestedMethodType.Instance;
                canonicalDataCase.SetConstructorInputParameters("bucket_one", "bucket_two", "start_bucket");

                var start_bucket = canonicalDataCase.Properties["start_bucket"];
                canonicalDataCase.Properties["start_bucket"] = new UnescapedValue(start_bucket == "two" ? "Bucket.Two" : "Bucket.One");
            }
        }

        protected override string RenderTestMethodBodyAct(TestMethodBody testMethodBody)
        {
            const string template = @"var result = {{MethodInvocation}};";

            var templateParameters = new
            {
                MethodInvocation = testMethodBody.Data.TestedMethodInvocation
            };

            return TemplateRenderer.RenderInline(template, templateParameters);
        }

        protected override string RenderTestMethodBodyAssert(TestMethodBody testMethodBody)
        {
            const string template =
@"Assert.Equal({{MovesExpected}}, result.Moves);
Assert.Equal({{OtherBucketExpected}}, result.OtherBucket);
Assert.Equal({% if GoalBucketExpected == 'two' %}Bucket.Two{% else %}Bucket.One{% endif %}, result.GoalBucket);";

            var templateParameters = new
            {
                MovesExpected = testMethodBody.CanonicalDataCase.Expected["moves"],
                OtherBucketExpected = testMethodBody.CanonicalDataCase.Expected["other_bucket"],
                GoalBucketExpected = testMethodBody.CanonicalDataCase.Expected["goal_bucket"],
            };

            return TemplateRenderer.RenderInline(template, templateParameters);
        }
    }
}

Version data entries

86 entries across 86 versions & 1 rubygems

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