Exemplo n.º 1
0
        public void WhenModeButtonIsClicked_LoadsStopwatchBehavior()
        {
            var clock = A.Fake <IClock>();

            _behavior.Load(clock);
            _behavior.OnClick(new ModeClick());
            A.CallTo(() => clock.SwitchBehavior <StopwatchBehavior>()).MustHaveHappened();
        }
Exemplo n.º 2
0
 public void SetUp()
 {
     _clockDisplay  = A.Fake <IClockDisplay>();
     _testableClock = new TestableClock()
     {
         Display = _clockDisplay
     };
     _behavior = new TimeBehavior();
     _behavior.Load(_testableClock);
 }
Exemplo n.º 3
0
        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();
        }
Exemplo n.º 4
0
        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();
        }
Exemplo n.º 5
0
        /// <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);
        }