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.151 tracks/csharp/generators/Exercises/TwoBucket.cs
trackler-2.2.1.150 tracks/csharp/generators/Exercises/TwoBucket.cs
trackler-2.2.1.149 tracks/csharp/generators/Exercises/TwoBucket.cs
trackler-2.2.1.148 tracks/csharp/generators/Exercises/TwoBucket.cs
trackler-2.2.1.147 tracks/csharp/generators/Exercises/TwoBucket.cs
trackler-2.2.1.146 tracks/csharp/generators/Exercises/TwoBucket.cs
trackler-2.2.1.145 tracks/csharp/generators/Exercises/TwoBucket.cs
trackler-2.2.1.144 tracks/csharp/generators/Exercises/TwoBucket.cs
trackler-2.2.1.143 tracks/csharp/generators/Exercises/TwoBucket.cs
trackler-2.2.1.142 tracks/csharp/generators/Exercises/TwoBucket.cs
trackler-2.2.1.141 tracks/csharp/generators/Exercises/TwoBucket.cs
trackler-2.2.1.140 tracks/csharp/generators/Exercises/TwoBucket.cs
trackler-2.2.1.139 tracks/csharp/generators/Exercises/TwoBucket.cs
trackler-2.2.1.138 tracks/csharp/generators/Exercises/TwoBucket.cs
trackler-2.2.1.137 tracks/csharp/generators/Exercises/TwoBucket.cs
trackler-2.2.1.136 tracks/csharp/generators/Exercises/TwoBucket.cs
trackler-2.2.1.135 tracks/csharp/generators/Exercises/TwoBucket.cs
trackler-2.2.1.134 tracks/csharp/generators/Exercises/TwoBucket.cs
trackler-2.2.1.133 tracks/csharp/generators/Exercises/TwoBucket.cs
trackler-2.2.1.132 tracks/csharp/generators/Exercises/TwoBucket.cs