Fix null phase data in timetable overview
This commit is contained in:
@@ -262,6 +262,27 @@ public sealed class TimetableViewModelTests
|
||||
Assert.False(cell.HasExperiment);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Load_Wochenkachel_UnvollstaendigePhasendaten_VerursachenKeinenFehler()
|
||||
{
|
||||
var group = new LearningGroup { Name = "Q1 Chemie" };
|
||||
var date = DateInCurrentWeek(DayOfWeek.Monday);
|
||||
var slots = new FakeTimetableSlots();
|
||||
slots.Add(new TimetableSlot { GroupId = group.Id, Weekday = DayOfWeek.Monday, PeriodNumber = 1 });
|
||||
var lessons = new FakeLessons();
|
||||
lessons.Add(new Lesson
|
||||
{
|
||||
GroupId = group.Id,
|
||||
Date = date,
|
||||
Phases = [new LessonPhaseStep { Name = null!, Activity = null!, Material = "Experimentiermaterial" }],
|
||||
});
|
||||
|
||||
var vm = BuildViewModel(slots, new FakeGroups([group]), lessons: lessons);
|
||||
|
||||
var cell = vm.WeekItems.Single(c => c.IsSlotCell && c.Weekday == DayOfWeek.Monday && c.PeriodNumber == 1);
|
||||
Assert.True(cell.HasExperiment);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Load_Wochenkachel_LetzteStundeVorKlausur_ZeigtIcon()
|
||||
{
|
||||
|
||||
@@ -387,10 +387,10 @@ public partial class TimetableViewModel : ObservableObject
|
||||
}
|
||||
|
||||
private static bool MentionsExperiment(Lesson? lesson) =>
|
||||
lesson is not null && lesson.Phases.Any(p =>
|
||||
p.Name.Contains("Experiment", StringComparison.OrdinalIgnoreCase) ||
|
||||
p.Activity.Contains("Experiment", StringComparison.OrdinalIgnoreCase) ||
|
||||
p.Material.Contains("Experiment", StringComparison.OrdinalIgnoreCase));
|
||||
lesson?.Phases?.Any(p => p is not null &&
|
||||
(p.Name?.Contains("Experiment", StringComparison.OrdinalIgnoreCase) == true ||
|
||||
p.Activity?.Contains("Experiment", StringComparison.OrdinalIgnoreCase) == true ||
|
||||
p.Material?.Contains("Experiment", StringComparison.OrdinalIgnoreCase) == true)) == true;
|
||||
|
||||
/// <summary>Fällt <paramref name="date"/> auf einen gesetzlichen Feiertag oder in Schulferien?</summary>
|
||||
private static bool IsFreeDay(DateOnly date, List<SchoolHoliday> schoolHolidays, HashSet<DateOnly> publicHolidayDates) =>
|
||||
|
||||
Reference in New Issue
Block a user