Sha256: ceee71398e6ab872823d0fb9790e6fc1ea36117dab5f581dd72e74b828525b67

Contents?: true

Size: 842 Bytes

Versions: 52

Compression:

Stored size: 842 Bytes

Contents

using System.IO;
using Serilog;

namespace Generators.Output
{
    public class ExerciseWriter
    {
        public virtual void WriteToFile(Exercise exercise)
        {
            var testClassFilePath = TestClassFilePath(exercise);
            var testClassContents = exercise.Render();

            Directory.CreateDirectory(Path.GetDirectoryName(testClassFilePath));
            File.WriteAllText(testClassFilePath, testClassContents);

            Log.Information("Generated tests for {Exercise} exercise in {TestFile}", exercise.Name, testClassFilePath);
        }

        private static string TestClassFilePath(Exercise exercise) => Path.Combine("..", "exercises", exercise.Name, TestClassFileName(exercise));

        private static string TestClassFileName(Exercise exercise) => $"{exercise.Name.ToTestClassName()}.cs";
    }
}

Version data entries

52 entries across 52 versions & 1 rubygems

Version Path
trackler-2.2.1.64 tracks/csharp/generators/Output/ExerciseWriter.cs
trackler-2.2.1.63 tracks/csharp/generators/Output/ExerciseWriter.cs
trackler-2.2.1.62 tracks/csharp/generators/Output/ExerciseWriter.cs
trackler-2.2.1.61 tracks/csharp/generators/Output/ExerciseWriter.cs
trackler-2.2.1.60 tracks/csharp/generators/Output/ExerciseWriter.cs
trackler-2.2.1.59 tracks/csharp/generators/Output/ExerciseWriter.cs
trackler-2.2.1.58 tracks/csharp/generators/Output/ExerciseWriter.cs
trackler-2.2.1.57 tracks/csharp/generators/Output/ExerciseWriter.cs
trackler-2.2.1.56 tracks/csharp/generators/Output/ExerciseWriter.cs
trackler-2.2.1.55 tracks/csharp/generators/Output/ExerciseWriter.cs
trackler-2.2.1.54 tracks/csharp/generators/Output/ExerciseWriter.cs
trackler-2.2.1.53 tracks/csharp/generators/Output/ExerciseWriter.cs
trackler-2.2.1.52 tracks/csharp/generators/Output/ExerciseWriter.cs
trackler-2.2.1.51 tracks/csharp/generators/Output/ExerciseWriter.cs
trackler-2.2.1.50 tracks/csharp/generators/Output/ExerciseWriter.cs
trackler-2.2.1.49 tracks/csharp/generators/Output/ExerciseWriter.cs
trackler-2.2.1.48 tracks/csharp/generators/Output/ExerciseWriter.cs
trackler-2.2.1.47 tracks/csharp/generators/Output/ExerciseWriter.cs
trackler-2.2.1.46 tracks/csharp/generators/Output/ExerciseWriter.cs
trackler-2.2.1.45 tracks/csharp/generators/Output/ExerciseWriter.cs