From a99591fc3c8981c742bfb789266c708aea5413c1 Mon Sep 17 00:00:00 2001 From: Xander Sigler Date: Wed, 26 Jan 2022 21:38:55 -0800 Subject: [PATCH] Throw exception if input not found --- .drone.yml | 1 + AOC2021.Test/AOCTester.cs | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.drone.yml b/.drone.yml index af00103..d47a933 100644 --- a/.drone.yml +++ b/.drone.yml @@ -11,6 +11,7 @@ steps: - name: test image: mcr.microsoft.com/dotnet/sdk:5.0 commands: + - ls - dotnet test AOC2021.Test - name: build-aoc-2021 diff --git a/AOC2021.Test/AOCTester.cs b/AOC2021.Test/AOCTester.cs index b45c30c..b4aa68d 100644 --- a/AOC2021.Test/AOCTester.cs +++ b/AOC2021.Test/AOCTester.cs @@ -19,7 +19,6 @@ namespace AOC2021.Test Console.WriteLine($"Testing {request.Day} Part A, Test data"); if (!string.IsNullOrEmpty(request.Answer.Day_A_Test)) response.Answer.Day_A_Test = GetAOCDay(request.Day).ExecuteDay(new AOCRequest() { Input = test, Version = AOCVersion.A }).Answer; - Console.WriteLine(response); Console.WriteLine(response.Answer.Day_A_Test); Console.WriteLine($"Testing {request.Day} Part A, Input data"); if (!string.IsNullOrEmpty(request.Answer.Day_A_Input)) @@ -57,16 +56,18 @@ namespace AOC2021.Test private string GetTextInput(string day, string type) { + var constructedFileName = $"Input\\{day}_{type}.txt"; + Console.WriteLine("ConstructedFileName: " + constructedFileName); + Console.WriteLine("Input File Size: " + Directory.GetFiles("Input").Length); foreach (var file in Directory.GetFiles("Input")) { - var constructedFileName = $"Input\\{day}_{type}.txt"; if (file.ToLower().Equals(constructedFileName.ToLower())) { Console.WriteLine("Loading " + file); return File.ReadAllText(file); } } - return null; + throw new Exception($"No Text Input found for {day} {type}"); } } }