Skip to content

Instantly share code, notes, and snippets.

@anaisbetts
Created February 28, 2011 01:24
Show Gist options
  • Select an option

  • Save anaisbetts/846793 to your computer and use it in GitHub Desktop.

Select an option

Save anaisbetts/846793 to your computer and use it in GitHub Desktop.
[TestMethod]
public void TimerShouldFinishAfterThirtyMinutes()
{
(new TestScheduler()).With(sched => {
var lastState = BlockTimerViewState.Initialized;
bool isTimerStateDone = false;
var fixture = new BlockTimerViewModel(new BlockItem() {
Description = "Test Item"
});
// Watch the Pomodoro timer state
fixture.TimerState.Subscribe(
state => lastState = state,
() => isTimerStateDone = true);
// Click the Start button
fixture.Start.Execute(null);
// Fast forward to 24 minutes in, the timer should *not* be done
sched.RunToMilliseconds(24 * 60 * 1000);
Assert.IsFalse(isTimerStateDone);
// Let's go to 35 minutes
sched.RunToMilliseconds(35 * 60 * 1000);
// Make sure our model duration took 30 minutes(ish)
TimeSpan pomodoroLength =
(fixture.Model.EndedAt.Value - fixture.Model.StartedAt.Value);
pomodoroLength.TotalMinutes.AssertWithinEpsilonOf(30.0);
Assert.IsTrue(isTimerStateDone);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment