57 lines
2.3 KiB
C#
57 lines
2.3 KiB
C#
using LehrerApp.Core.Models;
|
|
using LehrerApp.Core.Services;
|
|
using Xunit;
|
|
|
|
namespace LehrerApp.Desktop.Tests;
|
|
|
|
public sealed class PersonalDataExportServiceTests
|
|
{
|
|
[Fact]
|
|
public void ExportAsJson_EnthaeltNotenMitarbeitUndDokumentationDesSchuelers()
|
|
{
|
|
var studentId = Guid.NewGuid();
|
|
var groupId = Guid.NewGuid();
|
|
var student = new Student { Id = studentId, FirstName = "Anna", LastName = "Beispiel" };
|
|
|
|
var students = new FakeStudents([student]);
|
|
var groups = new FakeGroups([new LearningGroup { Id = groupId, Name = "Q1 Chemie" }]);
|
|
var memberships = new FakeMemberships([new GroupMembership { StudentId = studentId, GroupId = groupId }]);
|
|
var grades = new FakeGrades();
|
|
grades.Add(new Grade { StudentId = studentId, GroupId = groupId, Value = "2", Category = GradeCategory.Oral });
|
|
var results = new FakeResults();
|
|
var entries = new FakeEntries();
|
|
entries.Add(new ParticipationEntry { StudentId = studentId, SessionId = Guid.NewGuid() });
|
|
var documentation = new FakeDocumentation();
|
|
documentation.Add(new Documentation { StudentId = studentId, Title = "Elterngespräch" });
|
|
|
|
var seatingPlans = new FakeSeatingPlans([
|
|
new SeatingPlan
|
|
{
|
|
GroupId = groupId, Name = "Standard", Room = "B204",
|
|
Assignments = [new SeatAssignment { Row = 1, Column = 2, StudentId = studentId }],
|
|
},
|
|
]);
|
|
var service = new PersonalDataExportService(students, groups, memberships, grades, results, entries,
|
|
documentation, seatingPlans);
|
|
|
|
var json = service.ExportAsJson(studentId);
|
|
|
|
Assert.Contains("Anna", json);
|
|
Assert.Contains("Elterngespräch", json);
|
|
Assert.Contains("\"Value\": \"2\"", json);
|
|
Assert.Contains("\"Sitzplan\": \"Standard\"", json);
|
|
Assert.Contains("\"Reihe\": 2", json);
|
|
}
|
|
|
|
[Fact]
|
|
public void ExportAsJson_UnbekannterSchueler_WirftException()
|
|
{
|
|
var service = new PersonalDataExportService(
|
|
new FakeStudents([]), new FakeGroups([]), new FakeMemberships([]),
|
|
new FakeGrades(), new FakeResults(), new FakeEntries(), new FakeDocumentation(),
|
|
new FakeSeatingPlans());
|
|
|
|
Assert.Throws<InvalidOperationException>(() => service.ExportAsJson(Guid.NewGuid()));
|
|
}
|
|
}
|