Kapitel 7 abgeschlossen.

This commit is contained in:
2026-08-16 00:29:01 +02:00
parent da8d2bb1da
commit f9e398b225
47 changed files with 2636 additions and 107 deletions
+12 -3
View File
@@ -8,11 +8,20 @@ namespace LehrerApp.Desktop.Tests;
public class FakeStudents(List<Student> all) : IStudentRepository
{
private readonly Dictionary<Guid, StudentReferenceSummary> _references = [];
public Student? GetById(Guid id) => all.FirstOrDefault(s => s.Id == id);
public List<Student> GetAll(bool includeInactive = false) => all;
public List<Student> GetAll(bool includeInactive = false) =>
includeInactive ? all.ToList() : all.Where(s => s.IsActive).ToList();
public List<Student> GetByGroup(Guid groupId) => all;
public void Save(Student student) { }
public void Delete(Guid id) { }
public StudentReferenceSummary GetReferenceSummary(Guid studentId) =>
_references.GetValueOrDefault(studentId, new StudentReferenceSummary(0, 0, 0, 0, 0, 0));
public void SetReferenceSummary(Guid studentId, StudentReferenceSummary summary) => _references[studentId] = summary;
public void Save(Student student) { all.RemoveAll(s => s.Id == student.Id); all.Add(student); }
public void Delete(Guid id)
{
if (GetReferenceSummary(id).HasReferences) throw new InvalidOperationException();
all.RemoveAll(s => s.Id == id);
}
}
public class FakeMemberships(List<GroupMembership> all) : IGroupMembershipRepository