public void WhenModeButtonIsClicked_LoadsStopwatchBehavior() { var clock = A.Fake <IClock>(); _behavior.Load(clock); _behavior.OnClick(new ModeClick()); A.CallTo(() => clock.SwitchBehavior <StopwatchBehavior>()).MustHaveHappened(); }
public void SetUp() { _clockDisplay = A.Fake <IClockDisplay>(); _testableClock = new TestableClock() { Display = _clockDisplay }; _behavior = new TimeBehavior(); _behavior.Load(_testableClock); }
public void WhenLoadedWithDateTime_HooksTickEvent_SetsTime_And_UpdatesDisplay() { var behavior = new TimeBehavior(); var clock = new TestableClock(); var clockDisplay = A.Fake <IClockDisplay>(); clock.Display = clockDisplay; var previousValue = DateTime.Now; behavior.Load(clock, previousValue); clock.TriggerTickEvent(); behavior.Time.Should().Be(previousValue.AddSeconds(1.0)); A.CallTo(() => clockDisplay.TriggerUpdate(previousValue.ToDigitalClockFormat())).MustHaveHappened(); }
public void AfterLoadingBehavior_UpdatesDisplay() { var clock = A.Fake <IClock>(); var clockDisplay = A.Fake <IClockDisplay>(); clock.Display = clockDisplay; var time = DateTime.Now; var behavior = new TimeBehavior { Time = time }; behavior.Load(clock); A.CallTo(() => clockDisplay.TriggerUpdate(time.ToDigitalClockFormat())).MustHaveHappened(); }
/// <summary> /// Creates a new default clock with all of its properties /// </summary> /// <returns>The built clock</returns> public Clock Create() { var defaultBehavior = new TimeBehavior(); defaultBehavior.Time = DateTime.Now; var defaultDisplay = new DefaultDisplay(); var defaultClock = new Clock { Behavior = defaultBehavior, Display = defaultDisplay, TickControl = new DefaultClockTickControl() }; defaultBehavior.Load(defaultClock); return(defaultClock); }