Sha256: 8afffaff081c662bab95d0080d73a8162ac654c8dd0c959ec4f790e506dd65af

Contents?: true

Size: 1.77 KB

Versions: 86

Compression:

Stored size: 1.77 KB

Contents

using System;
using System.Collections.Generic;
using Generators.Input;
using Newtonsoft.Json.Linq;

namespace Generators.Exercises
{
    public class SaddlePoints : GeneratorExercise
    {
        protected override void UpdateCanonicalData(CanonicalData canonicalData)
        {
            foreach (var canonicalDataCase in canonicalData.Cases)
            {
                canonicalDataCase.TestedMethodType = TestedMethodType.Instance;
                canonicalDataCase.Property = "Calculate";
                canonicalDataCase.SetConstructorInputParameters("input");
                canonicalDataCase.UseVariablesForConstructorParameters = true;
                canonicalDataCase.UseVariablesForInput = true;
                canonicalDataCase.UseVariableForTested = true;
                canonicalDataCase.UseVariableForExpected = true;

                canonicalDataCase.Properties["input"] = (canonicalDataCase.Properties["input"] as JArray).ToObject<int[,]>();

                var array = canonicalDataCase.Expected as Array;

                if (array != null)
                {
                    canonicalDataCase.Expected = ToTupleCollection(array);
                }
            }
        }

        protected override HashSet<string> AddAdditionalNamespaces()
        {
            return new HashSet<string>
            {
                typeof(System.String).Namespace
            };
        }

        private IEnumerable<Tuple<string, object>> ToTupleCollection(Array array)
        {
            for (int x = 0; x < array.GetLength(0); x++)
            {
                var current = ((Array)array).GetValue(x) as Dictionary<string, object>;
                yield return new Tuple<string, object>(current["row"].ToString(), current["column"].ToString());
            }
        }
    }
}

Version data entries

86 entries across 86 versions & 1 rubygems

Version Path
trackler-2.2.1.151 tracks/csharp/generators/Exercises/SaddlePoints.cs
trackler-2.2.1.150 tracks/csharp/generators/Exercises/SaddlePoints.cs
trackler-2.2.1.149 tracks/csharp/generators/Exercises/SaddlePoints.cs
trackler-2.2.1.148 tracks/csharp/generators/Exercises/SaddlePoints.cs
trackler-2.2.1.147 tracks/csharp/generators/Exercises/SaddlePoints.cs
trackler-2.2.1.146 tracks/csharp/generators/Exercises/SaddlePoints.cs
trackler-2.2.1.145 tracks/csharp/generators/Exercises/SaddlePoints.cs
trackler-2.2.1.144 tracks/csharp/generators/Exercises/SaddlePoints.cs
trackler-2.2.1.143 tracks/csharp/generators/Exercises/SaddlePoints.cs
trackler-2.2.1.142 tracks/csharp/generators/Exercises/SaddlePoints.cs
trackler-2.2.1.141 tracks/csharp/generators/Exercises/SaddlePoints.cs
trackler-2.2.1.140 tracks/csharp/generators/Exercises/SaddlePoints.cs
trackler-2.2.1.139 tracks/csharp/generators/Exercises/SaddlePoints.cs
trackler-2.2.1.138 tracks/csharp/generators/Exercises/SaddlePoints.cs
trackler-2.2.1.137 tracks/csharp/generators/Exercises/SaddlePoints.cs
trackler-2.2.1.136 tracks/csharp/generators/Exercises/SaddlePoints.cs
trackler-2.2.1.135 tracks/csharp/generators/Exercises/SaddlePoints.cs
trackler-2.2.1.134 tracks/csharp/generators/Exercises/SaddlePoints.cs
trackler-2.2.1.133 tracks/csharp/generators/Exercises/SaddlePoints.cs
trackler-2.2.1.132 tracks/csharp/generators/Exercises/SaddlePoints.cs