public void should_map() { var heartbeat = new Heartbeat { Message = "Kilroy was here", Date = new DateTime(2008, 3, 4), }; AssertObjectCanBePersisted(heartbeat); }
public void should_list_on_index() { var top = new Heartbeat[3]; var repository = S<IHeartbeatRepository>(); repository.Stub(x => x.GetTop()).Return(top); var controller = new HeartbeatController(repository, null); var result = controller.Index(); result.ViewData.Model.ShouldBeTheSameAs(top); }
public void should_report_success_when_heartbeat_is_within_the_specified_threshold() { var now = new DateTime(2010, 1, 3, 17, 2, 0); var nowMinusTwoMinutes = now.AddMinutes(-2); var heartbeat = new Heartbeat {Date = nowMinusTwoMinutes}; var timeout = 5; var repo = S<IHeartbeatRepository>(); repo.Stub(x => x.GetLatest()).Return(heartbeat); var clock = S<ISystemClock>(); clock.Stub(x => x.Now()).Return(now); var checker = new HeartbeatChecker(repo, clock); checker.CheckHeartbeat(timeout).ShouldEqual(HeartbeatChecker.Success); }
public void should_report_failure_when_the_last_heartbeat_is_too_old() { var now = new DateTime(2010, 1, 3, 17, 2, 0); var nowMinusTwoMinutes = now.AddMinutes(-2); var heartbeat = new Heartbeat { Date = nowMinusTwoMinutes }; var timeout = 1; var failureMessage = string.Format("DEAD! 1 minute threshold exceeded. Now [{0}], Last Heartbeat [{1}]", now, nowMinusTwoMinutes); var repo = S<IHeartbeatRepository>(); repo.Stub(x => x.GetLatest()).Return(heartbeat); var clock = S<ISystemClock>(); clock.Stub(x => x.Now()).Return(now); var checker = new HeartbeatChecker(repo, clock); checker.CheckHeartbeat(timeout).ShouldEqual(failureMessage); }
public void should_report_failure_when_the_last_heartbeat_is_in_the_future() { var now = new DateTime(2010, 1, 3, 17, 2, 0); var future = now.AddMinutes(2); var heartbeat = new Heartbeat { Date = future }; var timeout = 5; var failureMessage = string.Format("DEAD! Heartbeat is in the future. Now [{0}], Last Heartbeat [{1}]", now, future); var repo = S<IHeartbeatRepository>(); repo.Stub(x => x.GetLatest()).Return(heartbeat); var clock = S<ISystemClock>(); clock.Stub(x => x.Now()).Return(now); var checker = new HeartbeatChecker(repo, clock); checker.CheckHeartbeat(timeout).ShouldEqual(failureMessage); }