using LehrerApp.Core.Models; using LehrerApp.Desktop.ViewModels.Groups; using Xunit; namespace LehrerApp.Desktop.Tests; public sealed class QuickInputViewModelTests { [Fact] public void ZurueckZuVorherigemSchueler_ZeigtBereitsGesetzteBewertung() { var aspects = new List { new(new ParticipationAspect { Key = "mitarbeit", Label = "Mitarbeit" }), }; var rows = new List { new(Guid.NewGuid(), "Anna", new ParticipationEntry(), aspects, []), new(Guid.NewGuid(), "Ben", new ParticipationEntry(), aspects, []), }; var vm = new QuickInputViewModel(rows, aspects); vm.SetRatingByNumber(4); // Scale5, 4. Stufe -> Rohwert 1 ("+"), Anna bewerten vm.NextStudent(); // zu Ben vm.PreviousStudent(); // zurück zu Anna Assert.Equal(1, vm.AspectRows[0].Value); } [Fact] public void AnwesenderSchueler_CurrentStudentIsAbsent_IstFalse() { var aspects = new List { new(new ParticipationAspect { Key = "a", Label = "A" }), }; var rows = new List { new(Guid.NewGuid(), "Anna", new ParticipationEntry { Attendance = AttendanceStatus.Present }, aspects, []), }; var vm = new QuickInputViewModel(rows, aspects); Assert.False(vm.CurrentStudentIsAbsent); Assert.Equal(1.0, vm.CurrentStudentContentOpacity); } [Fact] public void AbwesenderSchueler_CurrentStudentIsAbsent_IstTrueUndGedimmt() { var aspects = new List { new(new ParticipationAspect { Key = "a", Label = "A" }), }; var rows = new List { new(Guid.NewGuid(), "Anna", new ParticipationEntry(), aspects, []), new(Guid.NewGuid(), "Ben", new ParticipationEntry { Attendance = AttendanceStatus.Unexcused }, aspects, []), }; var vm = new QuickInputViewModel(rows, aspects); vm.NextStudent(); // zu Ben, unentschuldigt abwesend Assert.True(vm.CurrentStudentIsAbsent); Assert.Equal("Krank, unentschuldigt", vm.CurrentStudentAttendanceLabel); Assert.Equal(0.4, vm.CurrentStudentContentOpacity); } [Fact] public void VorherigerAspekt_SpringtRueckwaertsMitUmlauf() { var aspects = new List { new(new ParticipationAspect { Key = "a", Label = "A" }), new(new ParticipationAspect { Key = "b", Label = "B" }), }; var rows = new List { new(Guid.NewGuid(), "Anna", new ParticipationEntry(), aspects, []), }; var vm = new QuickInputViewModel(rows, aspects); vm.PreviousAspect(); // von Index 0 rückwärts -> letzter Aspekt (Umlauf) Assert.Equal(1, vm.AspectIndex); } }