Skip to content

Feature Request: Support for "test mode" #211

@codemonkey85

Description

@codemonkey85

Every day's puzzle has some test input data (see https://adventofcode.com/2024/day/1 for instance). What I like to do (and what I assume everyone else does) is build my code around the test, checking that when I'm done, the output matches the provided test solution. However, what this library doesn't have is a way to directly support this pattern. What if we could hardcode the test data as a string in our Day code, and pass in a bool or something from the console to tell the app to use the test data instead of the input data?

For example:

namespace Advent2024.Days;

public sealed class Day01 : BaseDay
{
    private readonly string input = """
                                     3   4
                                     4   3
                                     2   5
                                     1   3
                                     3   9
                                     3   3
                                     """;

    public Day01(bool TestMode)
    {
        if (!TestMode)
        {
            input = File.ReadAllText(InputFilePath);
        }
    }

    public override ValueTask<string> Solve_1()
    {
        // Steps to solve part 1
        return new(string.Empty);
    }

    public override ValueTask<string> Solve_2()
    {
        // Steps to solve part 2
        return new(string.Empty);
    }
}

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions