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.131 tracks/csharp/generators/Exercises/TwoBucket.cs
trackler-2.2.1.130 tracks/csharp/generators/Exercises/TwoBucket.cs
trackler-2.2.1.129 tracks/csharp/generators/Exercises/TwoBucket.cs
trackler-2.2.1.128 tracks/csharp/generators/Exercises/TwoBucket.cs
trackler-2.2.1.127 tracks/csharp/generators/Exercises/TwoBucket.cs
trackler-2.2.1.126 tracks/csharp/generators/Exercises/TwoBucket.cs
trackler-2.2.1.125 tracks/csharp/generators/Exercises/TwoBucket.cs
trackler-2.2.1.124 tracks/csharp/generators/Exercises/TwoBucket.cs
trackler-2.2.1.123 tracks/csharp/generators/Exercises/TwoBucket.cs
trackler-2.2.1.122 tracks/csharp/generators/Exercises/TwoBucket.cs
trackler-2.2.1.121 tracks/csharp/generators/Exercises/TwoBucket.cs
trackler-2.2.1.120 tracks/csharp/generators/Exercises/TwoBucket.cs
trackler-2.2.1.119 tracks/csharp/generators/Exercises/TwoBucket.cs
trackler-2.2.1.118 tracks/csharp/generators/Exercises/TwoBucket.cs
trackler-2.2.1.117 tracks/csharp/generators/Exercises/TwoBucket.cs
trackler-2.2.1.116 tracks/csharp/generators/Exercises/TwoBucket.cs
trackler-2.2.1.115 tracks/csharp/generators/Exercises/TwoBucket.cs
trackler-2.2.1.114 tracks/csharp/generators/Exercises/TwoBucket.cs
trackler-2.2.1.113 tracks/csharp/generators/Exercises/TwoBucket.cs
trackler-2.2.1.111 tracks/csharp/generators/Exercises/TwoBucket.cs