public async Task <IActionResult> PostAsync([FromBody] ExerciseSolution exerciseSolution, [FromServices] IDockerClient dockerClient) { var runner = new NUnitTestRunner(dockerClient); var result = await runner.Run(exerciseSolution); return(Ok(result)); }
public async Task <ExerciseResult> Run(ExerciseSolution userSolution) { var container = await StartContainer(); var stream = await _dockerClient.Containers.AttachContainerAsync(container.ID, false, new ContainerAttachParameters { Stdin = true, Stdout = true, Stderr = true }); var output = await stream.ReadOutputToEndAsync(new CancellationToken()); Console.Write(output.stdout); await _dockerClient.Containers.StopContainerAsync(container.ID, new ContainerStopParameters()); return(new ExerciseResult { Message = "It worked I think", Success = true }); }