58 lines
2.2 KiB
C#
58 lines
2.2 KiB
C#
using LehrerApp.Core.Models;
|
|
using LehrerApp.Core.Services;
|
|
using Xunit;
|
|
|
|
namespace LehrerApp.Tests;
|
|
|
|
public class ExamScoringServiceTests
|
|
{
|
|
[Fact]
|
|
public void BonusUndFassungen_VerwendenJeweilsDenRichtigenGrundwert()
|
|
{
|
|
var tasks = new List<ExamTask>
|
|
{
|
|
new() { MaxPoints = 10 },
|
|
new() { MaxPoints = 5, Variant = ExamVariant.A },
|
|
new() { MaxPoints = 8, Variant = ExamVariant.B },
|
|
new() { MaxPoints = 2, IsBonus = true },
|
|
};
|
|
|
|
Assert.Equal(15, ExamScoringService.Maximum(tasks, ExamVariant.A));
|
|
Assert.Equal(18, ExamScoringService.Maximum(tasks, ExamVariant.B));
|
|
Assert.Equal(17, ExamScoringService.Achieved(tasks, [10, 5, 8, 2], ExamVariant.A));
|
|
Assert.Equal(20, ExamScoringService.Achieved(tasks, [10, 5, 8, 2], ExamVariant.B));
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(RepeatGradeRule.Better, GradingSystem.Grades1To6, "2", "4", "2")]
|
|
[InlineData(RepeatGradeRule.Better, GradingSystem.Points0To15, "8", "11", "11")]
|
|
[InlineData(RepeatGradeRule.Repeat, GradingSystem.Grades1To6, "2", "4", "4")]
|
|
[InlineData(RepeatGradeRule.Original, GradingSystem.Grades1To6, "2", "4", "2")]
|
|
public void Wiederholung_ZaehltGenauEinmalNachRegel(RepeatGradeRule rule,
|
|
GradingSystem system, string first, string second, string expected)
|
|
{
|
|
var original = new Exam();
|
|
var repeat = new Exam { RepeatOfExamId = original.Id, RepeatGradeRule = rule };
|
|
var other = new Exam();
|
|
|
|
var grades = ExamScoringService.EffectiveGrades(
|
|
[(original, first), (repeat, second), (other, "3")], system);
|
|
|
|
Assert.Equal(2, grades.Count);
|
|
Assert.Contains(expected, grades);
|
|
Assert.Contains("3", grades);
|
|
}
|
|
|
|
[Fact]
|
|
public void Wiederholung_BessereNoteBeruecksichtigtTendenzUndFehlendesErgebnis()
|
|
{
|
|
var original = new Exam();
|
|
var repeat = new Exam { RepeatOfExamId = original.Id };
|
|
|
|
Assert.Equal(["2+"], ExamScoringService.EffectiveGrades(
|
|
[(original, "2"), (repeat, "2+")], GradingSystem.Grades1To6));
|
|
Assert.Equal(["2"], ExamScoringService.EffectiveGrades(
|
|
[(original, "2")], GradingSystem.Grades1To6));
|
|
}
|
|
}
|