public void DiqualifyVM() { TestDataGenerator tg = new TestDataGenerator(); tg.createRaceParticipants(10); var race = tg.Model.GetRace(0); var run = race.GetRun(0); var disqualifyVM = new DiqualifyVM(run); // Test whether all participants are part of disqualify Assert.AreEqual(10, disqualifyVM.GetGridView().Count); foreach (var rr in disqualifyVM.GetGridView()) { Assert.IsNull(rr.Runtime); } // Test for updating RunResult { run.SetRunTime(race.GetParticipant(3), new TimeSpan(0, 1, 3)); var rr = disqualifyVM.GetGridView().First(r => r.StartNumber == 3); Assert.AreEqual(new TimeSpan(0, 1, 3), rr.Runtime); } // Test for delete RunResult { run.DeleteRunResult(race.GetParticipant(3)); var rr = disqualifyVM.GetGridView().First(r => r.StartNumber == 3); Assert.IsNull(rr.Runtime); } }
private void connectUiToRaceRun(RaceRun raceRun) { if (raceRun != null) { if (_viewDisqualifications == null) { _viewDisqualifications = new CollectionViewSource(); _viewDisqualifications.LiveFilteringProperties.Add(nameof(RunResult.Runtime)); _viewDisqualifications.LiveFilteringProperties.Add(nameof(RunResult.ResultCode)); _viewDisqualifications.IsLiveFilteringRequested = true; } _disqualificationsVM = new DiqualifyVM(raceRun); _viewDisqualifications.Source = _disqualificationsVM.GetGridView(); dgDisqualifications.ItemsSource = _viewDisqualifications.View; dgResults.ItemsSource = raceRun.GetResultViewProvider().GetView(); cmbResultGrouping.SelectCBItem(raceRun.GetResultViewProvider().ActiveGrouping); } else { _disqualificationsVM = null; dgDisqualifications.ItemsSource = null; dgResults.ItemsSource = null; } }