private async Task RunTests(Guid taskId, Guid solutionId) { var solutionSource = await fileRepo.ReadSourceCode(solutionId).ConfigureAwait(false); if (solutionSource == null) { return; } var testCases = (await fileRepo.ReadTests(taskId).ConfigureAwait(false)).ToArray(); var firstFailedNumber = -1; string firstFailedError = null; var passedCount = 0; for (var i = 0; i < testCases.Length; i++) { var testCase = testCases[i]; var argumentArray = testCase.Input.Split().Where(x => !string.IsNullOrWhiteSpace(x)).ToArray(); var testRunResult = jsRunner.Execute(solutionSource, argumentArray); if (testRunResult.IsSuccess) { if (testRunResult.Output == testCase.CorrectOutput) { passedCount++; } else if (firstFailedNumber == -1) { firstFailedNumber = i + 1; firstFailedError = "Wrong answer"; } } else if (firstFailedNumber == -1) { firstFailedNumber = i + 1; firstFailedError = testRunResult.ErrorMessage; } } await MarkFinished(taskId, solutionId, passedCount, testCases.Length, firstFailedNumber, firstFailedError).ConfigureAwait(false); }