Fix Untis homework comparison and student selection

This commit is contained in:
admin committed 2026-09-25 21:33:54 +02:00
1 parent 1291b24478
commit f3e23ad207
8 files changed
+372 -66

No files matched your search

@@ -1,4 +1,5 @@
using LehrerApp.Desktop.ViewModels.ClassTeacher;
using LehrerApp.Core.Models;
using Xunit;
namespace LehrerApp.Desktop.Tests;
@@ -28,4 +29,32 @@ public sealed class UntisNameMatchingTests
{
Assert.True(UntisNameMatching.NamesMatch("Gerste, Amelia", "Gerste Amelia"));
}
[Fact]
public void BuildClassNameIndex_VerwendetDieselbeInstanzWieDieAuswahlliste()
{
var candidate = new Student { FirstName = "Amelia", LastName = "Gerste" };
var repositoryCopy = new Student
{
Id = candidate.Id, FirstName = candidate.FirstName, LastName = candidate.LastName,
};
var index = UntisNameMatching.BuildClassNameIndex([candidate], [repositoryCopy]);
Assert.Same(candidate, index[UntisNameMatching.NameKey("Gerste Amelia")]);
}
[Fact]
public void BuildClassNameIndex_GleicheNamenInVerschiedenenKlassenBleibenEindeutig()
{
var classStudent = new Student { FirstName = "Amelia", LastName = "Gerste" };
var otherStudent = new Student { FirstName = "Amelia", LastName = "Gerste" };
var candidates = new[] { classStudent, otherStudent };
Assert.Empty(UntisNameMatching.BuildNameIndex(candidates));
var index = UntisNameMatching.BuildClassNameIndex(candidates,
[new Student { Id = classStudent.Id, FirstName = "Amelia", LastName = "Gerste" }]);
Assert.Same(classStudent, index[UntisNameMatching.NameKey("Gerste Amelia")]);
}
}