Add animated classroom grouping with saved editable plans
CI / build-and-test (push) Canceled after 0s
CI / build-and-test (push) Canceled after 0s
This commit is contained in:
1 parent
d4b1419f9a
commit
f0462bd2a1
27 files changed
+775
-46
No files matched your search
@@ -8,6 +8,72 @@ public sealed class RepositoryTests
|
||||
{
|
||||
private static LiteDbContext NewInMemoryContext() => new(new MemoryStream());
|
||||
|
||||
[Fact]
|
||||
public void StudentGroupPlanRepository_SpeichertEinteilungUndLoeschtSieMitDerLerngruppe()
|
||||
{
|
||||
using var db = NewInMemoryContext();
|
||||
var group = new LearningGroup { Name = "8a" };
|
||||
new GroupRepository(db).Save(group);
|
||||
var studentIds = new[] { Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid() };
|
||||
var plan = new StudentGroupPlan
|
||||
{
|
||||
GroupId = group.Id,
|
||||
Name = " Projektwoche ",
|
||||
Groups =
|
||||
[
|
||||
new StudentGroupPlanGroup { StudentIds = [studentIds[0], studentIds[1]] },
|
||||
new StudentGroupPlanGroup { StudentIds = [studentIds[2]] },
|
||||
],
|
||||
};
|
||||
var changes = new List<(string Type, string Operation)>();
|
||||
db.OnChange = (type, _, operation, _) => changes.Add((type, operation));
|
||||
var repo = new StudentGroupPlanRepository(db);
|
||||
|
||||
repo.Save(plan);
|
||||
Assert.Equal("Projektwoche", repo.GetById(plan.Id)?.Name);
|
||||
Assert.Equal(studentIds[2], repo.GetByGroup(group.Id).Single().Groups[1].StudentIds.Single());
|
||||
Assert.Equal(plan.Id, Assert.Single(repo.GetByStudent(studentIds[0])).Id);
|
||||
Assert.Contains((nameof(StudentGroupPlan), "Save"), changes);
|
||||
|
||||
var student = new Student { Id = studentIds[0], FirstName = "Anna", LastName = "Beispiel" };
|
||||
var students = new StudentRepository(db);
|
||||
students.Save(student);
|
||||
Assert.Throws<InvalidOperationException>(() => students.Delete(student.Id));
|
||||
|
||||
new GroupRepository(db).Delete(group.Id);
|
||||
Assert.Empty(repo.GetByGroup(group.Id));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void StudentGroupPlanRepository_VerhindertDoppelteSchuelerUndNamen()
|
||||
{
|
||||
using var db = NewInMemoryContext();
|
||||
var group = new LearningGroup { Name = "8a" };
|
||||
new GroupRepository(db).Save(group);
|
||||
var repo = new StudentGroupPlanRepository(db);
|
||||
var studentId = Guid.NewGuid();
|
||||
Assert.Throws<InvalidOperationException>(() => repo.Save(new StudentGroupPlan
|
||||
{
|
||||
GroupId = group.Id, Name = "Doppelt",
|
||||
Groups =
|
||||
[
|
||||
new StudentGroupPlanGroup { StudentIds = [studentId] },
|
||||
new StudentGroupPlanGroup { StudentIds = [studentId] },
|
||||
],
|
||||
}));
|
||||
|
||||
repo.Save(new StudentGroupPlan
|
||||
{
|
||||
GroupId = group.Id, Name = "Projektwoche",
|
||||
Groups = [new StudentGroupPlanGroup { StudentIds = [studentId] }],
|
||||
});
|
||||
Assert.Throws<InvalidOperationException>(() => repo.Save(new StudentGroupPlan
|
||||
{
|
||||
GroupId = group.Id, Name = "projektwoche",
|
||||
Groups = [new StudentGroupPlanGroup()],
|
||||
}));
|
||||
}
|
||||
|
||||
// ── StudentRepository ─────────────────────────────────────────────────────
|
||||
|
||||
[Fact]
|
||||
|
||||
Reference in new issue
Block a user