public void ShouldSwitchTaskCountdownAndBreakCountdown() { Assert.AreEqual(2, pomodoro.GetMinute()); Assert.AreEqual(0, pomodoro.GetSecond()); Assert.AreEqual(PomodoroPhase.NotRunning, pomodoro.CurrentPhase); pomodoro.Tick(); Assert.AreEqual(1, pomodoro.GetMinute()); Assert.AreEqual(59, pomodoro.GetSecond()); Assert.AreEqual(PomodoroPhase.RunningTask, pomodoro.CurrentPhase); for (int i = 0; i < 119; i++) { pomodoro.Tick(); } bool onSwitchToBreakEventCalled = false; pomodoro.OnSwitchToBreak += new Action(() => onSwitchToBreakEventCalled = true); pomodoro.Tick(); Assert.IsTrue(onSwitchToBreakEventCalled); Assert.IsFalse(pomodoro.CountdownEnd); Assert.AreEqual(1, pomodoro.GetMinute()); Assert.AreEqual(0, pomodoro.GetSecond()); Assert.AreEqual(PomodoroPhase.WaitingSwitchToBreak, pomodoro.CurrentPhase); Assert.AreEqual(1, pomodoro.Progress); bool onSwitchToTaskEventCalled = false; pomodoro.OnSwitchToTask += new Action(() => onSwitchToTaskEventCalled = true); for (int i = 0; i < 60; i++) { pomodoro.Tick(); Assert.AreEqual(PomodoroPhase.RunningBreak, pomodoro.CurrentPhase); } pomodoro.Tick(); Assert.IsTrue(onSwitchToTaskEventCalled); Assert.IsFalse(pomodoro.CountdownEnd); Assert.AreEqual(2, pomodoro.GetMinute()); Assert.AreEqual(0, pomodoro.GetSecond()); Assert.AreEqual(PomodoroPhase.WaitingSwitchToTask, pomodoro.CurrentPhase); Assert.AreEqual(1, pomodoro.Progress); }
public void ShouldSwitchTaskCountdownAndBreakCountdown() { Assert.AreEqual(2, pomodoro.GetMinute()); Assert.AreEqual(0, pomodoro.GetSecond()); pomodoro.Tick(); Assert.AreEqual(1, pomodoro.GetMinute()); Assert.AreEqual(59, pomodoro.GetSecond()); for (int i = 0; i < 118; i++) { pomodoro.Tick(); } bool onSwitchToBreakEventCalled = false; pomodoro.OnSwitchToBreak += new Action(() => onSwitchToBreakEventCalled = true); pomodoro.Tick(); Assert.IsTrue(onSwitchToBreakEventCalled); Assert.IsFalse(pomodoro.CountdownEnd); Assert.AreEqual(1, pomodoro.GetMinute()); Assert.AreEqual(0, pomodoro.GetSecond()); bool onSwitchToTaskEventCalled = false; pomodoro.OnSwitchToTask += new Action(() => onSwitchToTaskEventCalled = true); for (int i = 0; i < 60; i++) { pomodoro.Tick(); } Assert.IsTrue(onSwitchToTaskEventCalled); Assert.IsFalse(pomodoro.CountdownEnd); Assert.AreEqual(2, pomodoro.GetMinute()); Assert.AreEqual(0, pomodoro.GetSecond()); }