Fixed the testing for Day 2

master
Xander Sigler 3 years ago
parent 59d50bfd5b
commit e295f7a119

@ -15,24 +15,23 @@ namespace AOC2021.Test
{
Console.WriteLine("Testing " + request.Day);
var response = new TestResponse() { Answer = new Models.Answer() };
var day = GetAOCDay(request.Day);
var test = GetTextInput(request.Day, "test");
var input = GetTextInput(request.Day, "input");
Console.WriteLine($"Testing {request.Day} Part A, Test data");
if (!string.IsNullOrEmpty(request.Answer.Day_A_Test))
response.Answer.Day_A_Test = day.ExecuteDay(new AOCRequest() { Input = test, Version = AOCVersion.A }).Answer;
response.Answer.Day_A_Test = GetAOCDay(request.Day).ExecuteDay(new AOCRequest() { Input = test, Version = AOCVersion.A }).Answer;
Console.WriteLine($"Testing {request.Day} Part A, Input data");
if (!string.IsNullOrEmpty(request.Answer.Day_A_Input))
response.Answer.Day_A_Input = day.ExecuteDay(new AOCRequest() { Input = input, Version = AOCVersion.A }).Answer;
response.Answer.Day_A_Input = GetAOCDay(request.Day).ExecuteDay(new AOCRequest() { Input = input, Version = AOCVersion.A }).Answer;
Console.WriteLine($"Testing {request.Day} Part B, Test data");
if (!string.IsNullOrEmpty(request.Answer.Day_B_Test))
response.Answer.Day_B_Test = day.ExecuteDay(new AOCRequest() { Input = test, Version = AOCVersion.B }).Answer;
response.Answer.Day_B_Test = GetAOCDay(request.Day).ExecuteDay(new AOCRequest() { Input = test, Version = AOCVersion.B }).Answer;
Console.WriteLine($"Testing {request.Day} Part B, Input data");
if (!string.IsNullOrEmpty(request.Answer.Day_B_Input))
response.Answer.Day_B_Input = day.ExecuteDay(new AOCRequest() { Input = input, Version = AOCVersion.B }).Answer;
response.Answer.Day_B_Input = GetAOCDay(request.Day).ExecuteDay(new AOCRequest() { Input = input, Version = AOCVersion.B }).Answer;
return response;
}

File diff suppressed because it is too large Load Diff

@ -22,14 +22,14 @@ namespace AOC2021.Test.Models
Answer a = (Answer)obj;
string failedAnswer = string.Empty;
if (!Day_A_Input.Equals(a.Day_A_Input))
failedAnswer = $"Failed Day A Input ({Day_A_Input}) vs ({a.Day_A_Input})";
throw new Exception($"Failed Day A Input ({Day_A_Input}) vs ({a.Day_A_Input})");
if (!Day_A_Test.Equals(a.Day_A_Test))
failedAnswer = $"Failed Day A Test ({Day_A_Test}) vs ({a.Day_A_Test})";
throw new Exception($"Failed Day A Test ({Day_A_Test}) vs ({a.Day_A_Test})");
if (!Day_B_Input.Equals(a.Day_B_Input))
failedAnswer = $"Failed Day B Input ({Day_B_Input}) vs ({a.Day_B_Input})";
throw new Exception($"Failed Day B Input ({Day_B_Input}) vs ({a.Day_B_Input})");
if (!Day_B_Test.Equals(a.Day_B_Test))
failedAnswer = $"Failed Day B Test ({Day_B_Test}) vs ({a.Day_B_Test})";
throw new Exception($"Failed Day B Test ({Day_B_Test}) vs ({a.Day_B_Test})");
if (string.IsNullOrEmpty(failedAnswer))
{

@ -20,7 +20,15 @@ namespace AOC2021
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddCors(options =>
{
options.AddPolicy("AnyOrigin", builder =>
{
builder
.AllowAnyOrigin()
.AllowAnyMethod();
});
});
services.AddControllers();
services.AddSwaggerGen(c =>
{
@ -33,6 +41,7 @@ namespace AOC2021
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseCors("AnyOrigin");
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();

Loading…
Cancel
Save