Schülerdokumentation: Einträge, Fehlzeitenbilanz, Datenschutz (Kapitel 5)
Dokumentationseinträge mit Typwahl (Gespräch, Vorkommnis, Förderplan, Fehlzeit, Elternanruf, Elternbrief), vertrauliche Einträge nur nach Bestätigung sichtbar, weiche Löschung mit Nachvollziehbarkeit. Fehlzeiten als Auswertung des bestehenden Anwesenheits-Trackings statt zweiter Erfassung, mit Schwellenwert-Warnung im Schülerdetail und Dashboard. Förderplan-Wiedervorlage als Dashboard-Karte. Datenschutz: Löschfristen mit manueller Bereinigung und DSGVO-Art.-15-Datenauskunft als Export. Auf Nutzer-Feedback hin ergänzt: Elternanruf mit begleitendem Gesprächsprotokoll-Dialog (Punkte abhaken, Eindrücke festhalten), Elternbrief mit Versand-/Rückmeldungs-Tracking, Datei-Anhänge über LiteDBs Dateispeicher, frei vergebbare Labels zur Nachverfolgung mit Dringlichkeits-Farbcodierung, sowie eine sichtbare Farblegende für das bestehende Notenentwicklungs-Diagramm. Dabei einen Absturz behoben: leere Textfelder lieferten über das Binding null statt "", was beim Speichern eine NullReferenceException auslöste. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
using Xunit;
|
||||
|
||||
// LiteDB nutzt einen statischen, geteilten BsonMapper.Global für die Reflection-basierte
|
||||
// Index-Auflösung (EnsureIndex mit Lambda-Ausdrücken). Bei paralleler Testausführung über
|
||||
// mehrere Testklassen hinweg (xUnit-Standard) konkurrieren mehrere Threads beim erstmaligen
|
||||
// Aufbau der Typ-Metadaten für verschiedene Modelle — das führt zu sporadischen
|
||||
// "Member X not found on BsonMapper"-Fehlern, die mit dem eigentlichen Testinhalt nichts zu
|
||||
// tun haben. Tests in diesem Projekt laufen deshalb sequenziell.
|
||||
[assembly: CollectionBehavior(DisableTestParallelization = true)]
|
||||
@@ -0,0 +1,59 @@
|
||||
using Xunit;
|
||||
|
||||
namespace LehrerApp.Data.Tests;
|
||||
|
||||
public sealed class LiteAttachmentStorageTests
|
||||
{
|
||||
private static LiteDbContext NewInMemoryContext() => new(new MemoryStream());
|
||||
|
||||
[Fact]
|
||||
public void Upload_OpenRead_RoundtripLiefertDenGespeichertenInhalt()
|
||||
{
|
||||
using var db = NewInMemoryContext();
|
||||
var storage = new LiteAttachmentStorage(db);
|
||||
var bytes = "Elternbrief-Inhalt äöü"u8.ToArray();
|
||||
|
||||
string id;
|
||||
using (var ms = new MemoryStream(bytes))
|
||||
id = storage.Upload("Brief.pdf", ms);
|
||||
|
||||
using var result = storage.OpenRead(id);
|
||||
Assert.NotNull(result);
|
||||
using var reader = new MemoryStream();
|
||||
result!.CopyTo(reader);
|
||||
Assert.Equal(bytes, reader.ToArray());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Upload_GroessereDateiAlsDasLimit_WirftException()
|
||||
{
|
||||
using var db = NewInMemoryContext();
|
||||
var storage = new LiteAttachmentStorage(db);
|
||||
using var ms = new MemoryStream(new byte[LehrerApp.Core.Interfaces.IAttachmentStorage.MaxSizeBytes + 1]);
|
||||
|
||||
Assert.Throws<InvalidOperationException>(() => storage.Upload("zu-gross.bin", ms));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void OpenRead_UnbekannteId_GibtNullZurueck()
|
||||
{
|
||||
using var db = NewInMemoryContext();
|
||||
var storage = new LiteAttachmentStorage(db);
|
||||
|
||||
Assert.Null(storage.OpenRead("fehlt"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Delete_EntferntDenAnhangEndgueltig()
|
||||
{
|
||||
using var db = NewInMemoryContext();
|
||||
var storage = new LiteAttachmentStorage(db);
|
||||
string id;
|
||||
using (var ms = new MemoryStream([1, 2, 3]))
|
||||
id = storage.Upload("a.bin", ms);
|
||||
|
||||
storage.Delete(id);
|
||||
|
||||
Assert.Null(storage.OpenRead(id));
|
||||
}
|
||||
}
|
||||
@@ -331,4 +331,73 @@ public sealed class RepositoryTests
|
||||
Assert.Throws<LiteDB.LiteException>(() =>
|
||||
db.ParticipationEntries.Insert(new ParticipationEntry { SessionId = sessionId, StudentId = studentId }));
|
||||
}
|
||||
|
||||
// ── DocumentationRepository ───────────────────────────────────────────────
|
||||
|
||||
[Fact]
|
||||
public void DocumentationRepository_Delete_MarkiertNurAlsGeloescht()
|
||||
{
|
||||
using var db = NewInMemoryContext();
|
||||
var repo = new DocumentationRepository(db);
|
||||
var doc = new Documentation { StudentId = Guid.NewGuid(), Title = "Gespräch" };
|
||||
repo.Save(doc);
|
||||
|
||||
repo.Delete(doc.Id);
|
||||
|
||||
Assert.Empty(repo.GetByStudent(doc.StudentId));
|
||||
var raw = db.Documentation.FindById(doc.Id);
|
||||
Assert.NotNull(raw);
|
||||
Assert.True(raw.IsDeleted);
|
||||
Assert.NotNull(raw.DeletedAt);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DocumentationRepository_HardDelete_EntferntDenEintragEndgueltig()
|
||||
{
|
||||
using var db = NewInMemoryContext();
|
||||
var repo = new DocumentationRepository(db);
|
||||
var doc = new Documentation { StudentId = Guid.NewGuid(), Title = "Vorkommnis" };
|
||||
repo.Save(doc);
|
||||
|
||||
repo.HardDelete(doc.Id);
|
||||
|
||||
Assert.Null(db.Documentation.FindById(doc.Id));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DocumentationRepository_GetAll_FiltertGeloeschteEintraegeUndUmfasstAlleSchueler()
|
||||
{
|
||||
using var db = NewInMemoryContext();
|
||||
var repo = new DocumentationRepository(db);
|
||||
var visible = new Documentation { StudentId = Guid.NewGuid(), Title = "Sichtbar" };
|
||||
var deleted = new Documentation { StudentId = Guid.NewGuid(), Title = "Gelöscht" };
|
||||
repo.Save(visible);
|
||||
repo.Save(deleted);
|
||||
repo.Delete(deleted.Id);
|
||||
|
||||
var all = repo.GetAll();
|
||||
|
||||
Assert.Single(all);
|
||||
Assert.Equal(visible.Id, all[0].Id);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DocumentationRepository_HardDelete_EntferntAuchDieAnhaenge()
|
||||
{
|
||||
using var db = NewInMemoryContext();
|
||||
var repo = new DocumentationRepository(db);
|
||||
var storage = new LiteAttachmentStorage(db);
|
||||
string attachmentId;
|
||||
using (var ms = new MemoryStream([1, 2, 3]))
|
||||
attachmentId = storage.Upload("brief.pdf", ms);
|
||||
|
||||
var doc = new Documentation { StudentId = Guid.NewGuid(), Title = "Elternbrief" };
|
||||
doc.Attachments.Add(new DocumentAttachment { StorageId = attachmentId, FileName = "brief.pdf", SizeBytes = 3 });
|
||||
repo.Save(doc);
|
||||
|
||||
repo.HardDelete(doc.Id);
|
||||
|
||||
Assert.Null(db.Documentation.FindById(doc.Id));
|
||||
Assert.Null(storage.OpenRead(attachmentId));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user