private TestResult assertResult(GraderResult result, string?exerciseName, string testName, GradingOutcomes expectedTestOutcome = GradingOutcomes.Graded)
        {
            if (result == null)
            {
                throw new ArgumentNullException();
            }
            Assert.IsTrue(result.HasResult, "result is empty");

            ExerciseResult exerciseResult;

            if (string.IsNullOrEmpty(exerciseName))
            {
                exerciseResult = result.Exercises.FirstOrDefault();
            }
            else
            {
                exerciseResult = result.Exercises.FirstOrDefault(er => er.ExerciseName == exerciseName);
            }
            Assert.IsNotNull(exerciseResult, "cannot find exercise");

            var testResult = exerciseResult.TestsResults.FirstOrDefault(tr => tr.TestName == testName);

            Assert.IsNotNull(testResult, "cannot find test");

            Assert.AreEqual(expectedTestOutcome, testResult.GradingOutcome);

            return(testResult);
        }
示例#2
0
        public void Write(string studentId, GraderResult graderResult)
        {
            updateHeaderRowWithExercises(graderResult.Exercises);

            var row = workSheet.CreateRow(nextRowIndex++);

            row.CreateCell(0, CellType.String).SetCellValueWithSanitize(studentId);

            foreach (var exercise in graderResult.Exercises)
            {
                var cellIndex = exerciseToColumnIndex[exercise.ExerciseName];

                var cell1 = row.CreateCell(cellIndex, CellType.String);
                cell1.SetCellValueWithSanitize(formatCommentForCell(exercise.TestsResults));

                var cell2 = row.CreateCell(cellIndex + 1, CellType.String);
                cell2.SetCellValue(exercise.SumResultPoints);

                if (exercise.GradingOutcome == GradingOutcomes.FailedToGrade)
                {
                    cell1.CellStyle = cell2.CellStyle = cellStyleFailure;
                }
                else if (exercise.GradingOutcome == GradingOutcomes.Inconclusive)
                {
                    cell1.CellStyle = cell2.CellStyle = cellStyleInconclusive;
                }
                else
                {
                    cell1.CellStyle = cellStyleComment;
                }
            }

            saveFile();
        }
        private static bool parseContent(string contentString, out GraderResult result)
        {
            var parser = new TestResultParser();
            var graderResultBuilder = new GraderResultBuilder();

            var outcome = parser.Parse(contentString.Split('#'), graderResultBuilder, NullLogger.Instance);

            result = graderResultBuilder.ToResult();
            return(outcome);
        }