Ejemplo n.º 1
0
 static void Main(string[] args)
 {
     var theTimeNow = DateTime.Now;
     var clock = new BerlinClock();
     Console.WriteLine("The berlin clock for {0} is ...\n", theTimeNow.ToString("hh:MM:ss"));
     Console.WriteLine(clock.Generate(theTimeNow));
     Console.ReadLine();
 }
        public ClockViewModel()
        {
            _clock = new BerlinClock();

            _timer = new DispatcherTimer();
            _timer.Interval = new TimeSpan(0, 0, 0, 0, 5);
            _timer.Tick += TimerTick;
            _timer.Start();
        }
        public void ShouldReturnTheRightValue(int hours, int minutes, int seconds, string expectedResult)
        {
            var topFirstRow = new RowGeneratorTopFirst();
            var topSecondRow = new RowGeneratorTopSecond();
            var bottomFirstRow = new RowGeneratorBottomFirst();
            var bottomSecondRow = new RowGeneratorBottomSecond();
            var yellowLampGen = new RowGeneratorYellowLamp();

            var clock = new BerlinClock(topFirstRow, topSecondRow, bottomFirstRow, bottomSecondRow, yellowLampGen);
            var result = clock.Generate(hours, minutes, seconds);
            Assert.That(result, Is.EqualTo(expectedResult));
        }
        public void ShouldGenerateInCorrectFormat()
        {
            const string expectedResult = "Y\nAAAA\nBBBB\nCCCCCCCCCCC\nDDDD";
            var topFirstRow = MockRepository.GenerateStub<IRowGenerator>();
            var topSecondRow = MockRepository.GenerateStub<IRowGenerator>();
            var bottomFirstRow = MockRepository.GenerateStub<IRowGenerator>();
            var bottomSecondRow = MockRepository.GenerateStub<IRowGenerator>();
            var yellowLampGen = MockRepository.GenerateStub<IRowGenerator>();

            topFirstRow.Expect(x => x.Generate(0)).Return("AAAA");
            topSecondRow.Expect(x => x.Generate(0)).Return("BBBB");
            bottomFirstRow.Expect(x => x.Generate(0)).Return("CCCCCCCCCCC");
            bottomSecondRow.Expect(x => x.Generate(0)).Return("DDDD");
            yellowLampGen.Expect(x => x.Generate(0)).Return("Y");

            var clock = new BerlinClock(topFirstRow, topSecondRow, bottomFirstRow, bottomSecondRow, yellowLampGen);
            var result = clock.Generate(0, 0, 0);
            Assert.That(result, Is.EqualTo(expectedResult));
        }