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