public async Task <ActionResult <SudokuSolution> > GetSolution( int id, [FromBody] BaseRequest request, [FromQuery] bool fullRecord = true) { if (await appsService.IsRequestValidOnThisLicense( request.AppId, request.License, request.RequestorId)) { var result = await solutionService.GetSolution(id, fullRecord); if (result.Success) { result.Message = ControllerMessages.StatusCode200(result.Message); return(Ok(result)); } else { result.Message = ControllerMessages.StatusCode404(result.Message); return(NotFound(result)); } } else { return(BadRequest(ControllerMessages.InvalidLicenseRequestMessage)); } }
public async Task IssueMessageIfGetSolutionFails() { // Arrange // Act var result = await sutFailure.GetSolution(1); // Assert Assert.That(result.Success, Is.False); Assert.That(result.Message, Is.EqualTo("Solution not Found")); Assert.That(result.Solution, Is.TypeOf <SudokuSolution>()); }
public async Task GetASolution() { // Arrange // Act var result = await sut.GetSolution(1); // Assert Assert.That(result.Success, Is.True); Assert.That(result.Message, Is.EqualTo("Solution Found")); Assert.That(result.Solution, Is.TypeOf <SudokuSolution>()); }
public object GetResult(SolutionsRequest request) { try { return(_service.GetSolution(request)); } catch (AdventOfCodeException e) { HttpContext.Response.StatusCode = e.Code; return(new ProblemDetails { Status = e.Code, Title = e.Title, Detail = e.Message }); } catch (Exception e) { // logging HttpContext.Response.StatusCode = 500; return(new ProblemDetails { Status = 500, Title = "Internal server error.", Detail = e.Message }); } }