Sha256: f065da2d9f48562054d068670d152d171c0f89941eddbaf005910a1f231307f6

Contents?: true

Size: 1.22 KB

Versions: 28

Compression:

Stored size: 1.22 KB

Contents

using System;
using System.Collections.Generic;
using Generators.Input;
using Generators.Output;
using Humanizer;

namespace Generators.Exercises
{
    public class Sublist : GeneratorExercise
    {
        protected override HashSet<string> AddAdditionalNamespaces() => new HashSet<string>() { typeof(IList<int>).Namespace };

        private UnescapedValue InputValues(int[] list)
        {
            var template = (list != null) ? string.Join(", ", Array.ConvertAll<int, string>(list, (x) => { return $"{x}"; })) : "";
            return new UnescapedValue($"new List<int>() {{ {template} }}".Replace("  ", " "));
        }
        protected override void UpdateCanonicalData(CanonicalData canonicalData)
        {
            foreach (var canonicalDataCase in canonicalData.Cases)
            {
                canonicalDataCase.Input["listOne"] = InputValues(canonicalDataCase.Input["listOne"] as int[]);
                canonicalDataCase.Input["listTwo"] = InputValues(canonicalDataCase.Input["listTwo"] as int[]);

                canonicalDataCase.Property = "classify";
                canonicalDataCase.Expected = new UnescapedValue($"SublistType.{(canonicalDataCase.Expected as string).Dehumanize()}");
            }
        }
    }
}

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/csharp/generators/Exercises/Sublist.cs
trackler-2.2.1.179 tracks/csharp/generators/Exercises/Sublist.cs
trackler-2.2.1.178 tracks/csharp/generators/Exercises/Sublist.cs
trackler-2.2.1.177 tracks/csharp/generators/Exercises/Sublist.cs
trackler-2.2.1.176 tracks/csharp/generators/Exercises/Sublist.cs
trackler-2.2.1.175 tracks/csharp/generators/Exercises/Sublist.cs
trackler-2.2.1.174 tracks/csharp/generators/Exercises/Sublist.cs
trackler-2.2.1.173 tracks/csharp/generators/Exercises/Sublist.cs
trackler-2.2.1.172 tracks/csharp/generators/Exercises/Sublist.cs
trackler-2.2.1.171 tracks/csharp/generators/Exercises/Sublist.cs
trackler-2.2.1.170 tracks/csharp/generators/Exercises/Sublist.cs
trackler-2.2.1.169 tracks/csharp/generators/Exercises/Sublist.cs
trackler-2.2.1.167 tracks/csharp/generators/Exercises/Sublist.cs
trackler-2.2.1.166 tracks/csharp/generators/Exercises/Sublist.cs
trackler-2.2.1.165 tracks/csharp/generators/Exercises/Sublist.cs
trackler-2.2.1.164 tracks/csharp/generators/Exercises/Sublist.cs
trackler-2.2.1.163 tracks/csharp/generators/Exercises/Sublist.cs
trackler-2.2.1.162 tracks/csharp/generators/Exercises/Sublist.cs
trackler-2.2.1.161 tracks/csharp/generators/Exercises/Sublist.cs
trackler-2.2.1.160 tracks/csharp/generators/Exercises/Sublist.cs