Sha256: efd003f7adc05bf77ee2ef34b9a1e51702d58934476e86717e85d6ce7944b196

Contents?: true

Size: 1.29 KB

Versions: 27

Compression:

Stored size: 1.29 KB

Contents

using System.Linq;
using Generators.Input;

namespace Generators.Output
{
    public static class TestClassGenerator
    {
        private static readonly BooleanTestMethodGenerator BooleanTestMethod = new BooleanTestMethodGenerator();
        private static readonly EqualityTestMethodGenerator EqualityTestMethod = new EqualityTestMethodGenerator();
        private static readonly ExceptionTestMethodGenerator ExceptionTestMethod = new ExceptionTestMethodGenerator();

        public static TestClass Create(Exercise exercise) => new TestClass
        {
            ClassName = exercise.Name.ToTestClassName(),
            TestMethods = exercise.CanonicalData.Cases.Select(canonicalDataCase => CreateTestMethod(canonicalDataCase, exercise)).ToArray(),
            CanonicalDataVersion = exercise.CanonicalData.Version
        };

        private static TestMethod CreateTestMethod(CanonicalDataCase canonicalDataCase, Exercise exercise)
        {
            if (canonicalDataCase.ExceptionThrown != null)
                return ExceptionTestMethod.Create(canonicalDataCase, exercise);

            if (canonicalDataCase.Expected is bool)
                return BooleanTestMethod.Create(canonicalDataCase, exercise);

            return EqualityTestMethod.Create(canonicalDataCase, exercise);
        }
    }
}

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
trackler-2.2.1.12 tracks/csharp/generators/Output/TestClassGenerator.cs
trackler-2.2.1.11 tracks/csharp/generators/Output/TestClassGenerator.cs
trackler-2.2.1.10 tracks/csharp/generators/Output/TestClassGenerator.cs
trackler-2.2.1.9 tracks/csharp/generators/Output/TestClassGenerator.cs
trackler-2.2.1.8 tracks/csharp/generators/Output/TestClassGenerator.cs
trackler-2.2.1.7 tracks/csharp/generators/Output/TestClassGenerator.cs
trackler-2.2.1.6 tracks/csharp/generators/Output/TestClassGenerator.cs
trackler-2.2.1.5 tracks/csharp/generators/Output/TestClassGenerator.cs
trackler-2.2.1.4 tracks/csharp/generators/Output/TestClassGenerator.cs
trackler-2.2.1.3 tracks/csharp/generators/Output/TestClassGenerator.cs
trackler-2.2.1.2 tracks/csharp/generators/Output/TestClassGenerator.cs
trackler-2.2.1.1 tracks/csharp/generators/Output/TestClassGenerator.cs
trackler-2.2.1.0 tracks/csharp/generators/Output/TestClassGenerator.cs
trackler-2.2.0.6 tracks/csharp/generators/Output/TestClassGenerator.cs
trackler-2.2.0.5 tracks/csharp/generators/Output/TestClassGenerator.cs
trackler-2.2.0.4 tracks/csharp/generators/Output/TestClassGenerator.cs
trackler-2.2.0.3 tracks/csharp/generators/Output/TestClassGenerator.cs
trackler-2.2.0.2 tracks/csharp/generators/Output/TestClassGenerator.cs
trackler-2.2.0.1 tracks/csharp/generators/Output/TestClassGenerator.cs
trackler-2.2.0.0 tracks/csharp/generators/Output/TestClassGenerator.cs