Example #1
0
        public void Format_When131701_ThenReturnsCorrectResult()
        {
            var timeModel = new BerlinTimeModel(
                false,
                new BitArray(BerlinClock.Classes.BerlinClock.DefaultSignalsPerRow).SetBits(2),
                new BitArray(BerlinClock.Classes.BerlinClock.DefaultSignalsPerRow).SetBits(3),
                new BitArray(BerlinClock.Classes.BerlinClock.MinuteSignalsPerRow).SetBits(3),
                new BitArray(BerlinClock.Classes.BerlinClock.DefaultSignalsPerRow).SetBits(2));

            Assert.AreEqual(
                stringFormatter.Format(timeModel),
                $"{O}{n}{R}{R}{O}{O}{n}{R}{R}{R}{O}{n}{Y}{Y}{R}{O}{O}{O}{O}{O}{O}{O}{O}{n}{Y}{Y}{O}{O}");
        }
Example #2
0
        public string Format(BerlinTimeModel timeModel)
        {
            var builder = new StringBuilder();

            builder.Append(timeModel.SecondSet ? YellowSignal : NoSignal).AppendLine();
            builder.Append(GetRowOfSignals(timeModel.FiveHours, RedSignal)).AppendLine();
            builder.Append(GetRowOfSignals(timeModel.Hours, RedSignal)).AppendLine();
            builder.Append(GetRowOfSignals(timeModel.FiveMinutes, YellowSignal,
                                           BerlinTimeModel.MinuteSignalsAlternateCount, RedSignal)).AppendLine();
            builder.Append(GetRowOfSignals(timeModel.Minutes, YellowSignal));

            return(builder.ToString());
        }
Example #3
0
        public void Format_When000000_ThenReturnsCorrectResult()
        {
            var timeModel = new BerlinTimeModel(
                true,
                new BitArray(BerlinClock.Classes.BerlinClock.DefaultSignalsPerRow),
                new BitArray(BerlinClock.Classes.BerlinClock.DefaultSignalsPerRow),
                new BitArray(BerlinClock.Classes.BerlinClock.MinuteSignalsPerRow),
                new BitArray(BerlinClock.Classes.BerlinClock.DefaultSignalsPerRow));

            Assert.AreEqual(
                stringFormatter.Format(timeModel),
                $"{Y}{n}{O}{O}{O}{O}{n}{O}{O}{O}{O}{n}{O}{O}{O}{O}{O}{O}{O}{O}{O}{O}{O}{n}{O}{O}{O}{O}");
        }