Kapitel 7 abgeschlossen.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user