private TextView GetTextViewForSubExercise(SubExercise subExercise) { switch (subExercise) { case SubExercise.Undefined: return(null); case SubExercise.LongLeft: return(mCounterLeftLongCalf); case SubExercise.ShortLeft: return(mCounterLeftShortCalf); case SubExercise.LongRight: return(mCounterRightLongCalf); case SubExercise.ShortRight: return(mCounterRightShortCalf); default: throw new ArgumentOutOfRangeException(nameof(subExercise), subExercise, null); } }
public ActiveSubExerciseChangedEventArgs(SubExercise oldSubExercise, SubExercise newSubExercise) { OldSubExercise = oldSubExercise; NewSubExercise = newSubExercise; }
private void SignalActiveSubExerciseChanged(SubExercise fromSubExercise, SubExercise toSubExercise) { ActiveSubExerciseChanged?.Invoke(this, new ActiveSubExerciseChangedEventArgs(fromSubExercise, toSubExercise)); }
public void ExerciseService_TimerTick_SignalsActiveSubExerciseChanged(int elapsedTicks, SubExercise expectedOldSubExercise, SubExercise expectedNewSubExercise) { // Arrange var actualOldSubExercise = SubExercise.Undefined; var actualNewSubExercise = SubExercise.Undefined; var stubTimerService = Substitute.For <ITimerService>(); var stubExerciseTrackerService = Substitute.For <IExerciseTrackerService>(); var unitUnderTest = ExerciseService.ExerciseServiceFromString(string.Empty, CreateTestExerciseConfiguration(), stubTimerService, stubExerciseTrackerService); bool handled = false; unitUnderTest.Run(); for (var i = 0; i < elapsedTicks - 1; i++) { stubTimerService.Elapsed += Raise.Event(); } unitUnderTest.ActiveSubExerciseChanged += (sender, args) => { if (!handled) { actualOldSubExercise = args.OldSubExercise; actualNewSubExercise = args.NewSubExercise; handled = true; } }; // Act stubTimerService.Elapsed += Raise.Event(); // Assert Assert.AreEqual(expectedOldSubExercise, actualOldSubExercise); Assert.AreEqual(expectedNewSubExercise, actualNewSubExercise); }