public void IdleMode_OnStoppingFromAnyMode() { IClock clock = new Pomodoro.Model.Clock(); clock.StartWork(); clock.Stop(); Assert.AreEqual(Mode.Idle, clock.Mode); clock.StartShortBreak(); clock.Stop(); Assert.AreEqual(Mode.Idle, clock.Mode); clock.StartLongBreak(); clock.Stop(); Assert.AreEqual(Mode.Idle, clock.Mode); }
public void IsRunning_ReturnsTrue_OnlyWhenRunning() { IClock clock = new Pomodoro.Model.Clock(_testDuration); clock.StartWork(); Assert.IsTrue(clock.IsRunning); clock.Stop(); Assert.IsFalse(clock.IsRunning); clock.StartShortBreak(); Assert.IsTrue(clock.IsRunning); clock.Stop(); Assert.IsFalse(clock.IsRunning); clock.StartLongBreak(); Assert.IsTrue(clock.IsRunning); clock.Stop(); Assert.IsFalse(clock.IsRunning); }
public void Stop_PriorToStartingAgain() { bool begin = true; // at the beginning, stopped will be false and its okay. bool stopped = false; bool workStarted = false; bool shortBreakStarted = false; bool longBreakStarted = false; Action test = () => { IClock clock = new Pomodoro.Model.Clock(_testDuration); clock.Stopped += (sender, e) => { stopped = true; }; clock.WorkStarted += (sender, e) => { if (begin) begin = false; else Assert.IsTrue(stopped); workStarted = true; stopped = false; }; clock.ShortBreakStarted += (sender, e) => { if (begin) begin = false; else Assert.IsTrue(stopped); shortBreakStarted = true; stopped = false; }; clock.LongBreakStarted += (sender, e) => { if (begin) begin = false; else Assert.IsTrue(stopped); longBreakStarted = true; stopped = false; }; clock.StartWork(); clock.StartShortBreak(); clock.StartLongBreak(); clock.StartWork(); clock.StartLongBreak(); clock.StartShortBreak(); clock.StartWork(); clock.Stop(); }; DispatcherHelper.ExecuteOnDispatcherThread(test, millisecondsToWait: 20); Assert.IsTrue(workStarted); Assert.IsTrue(shortBreakStarted); Assert.IsTrue(longBreakStarted); }
public void Stopping_MultipleTimes_Allowed() { IClock clock = new Pomodoro.Model.Clock(); clock.Stop(); Assert.AreEqual(Mode.Idle, clock.Mode); clock.Stop(); Assert.AreEqual(Mode.Idle, clock.Mode); clock.Stop(); Assert.AreEqual(Mode.Idle, clock.Mode); }