コード例 #1
0
 public virtual void ConstructorIsRobust()
 {
     Assert.DoesNotThrow(() =>
     {
         var x = new BerlinClock.Classes.BerlinClock();
     });
 }
コード例 #2
0
        public string ConvertTime(string aTime)
        {
            if (!IsValid(aTime))
            {
                throw new Exception("Time format is not valid");
            }

            var time = Parse(aTime);

            var clock = new BerlinClock(new LampRowBuilder(), time);

            return(clock.ToString());
        }
コード例 #3
0
        public static BerlinClock FromTime(Time time)
        {
            var builder = new BerlinClockBuilder();
            var result  = builder.BuildBerlinClockRepresentation(time);

            var clock = new BerlinClock()
            {
                Time    = time,
                TimeStr = result
            };

            return(clock);
        }
コード例 #4
0
        public string convertTime(string aTime)
        {
            ITime time = new TimeString(aTime);

            IBerlinClock berlinClock = new BerlinClock.Classes.BerlinClock(time);

            string result = berlinClock.getSeconds() + "\r\n"
                            + berlinClock.getHoursTimes5() + "\r\n"
                            + berlinClock.GetHoursTimes1() + "\r\n"
                            + berlinClock.getMinutesTimes5() + "\r\n"
                            + berlinClock.GetMinutsTimes1();

            return(result);
        }
        public void WhenTheTimeIs_MiddleOfTheAfternoon()
        {
            int hours = 13;
            int minutes = 17;
            int seconds = 01;
            string expectedResult = "O\nRROO\nRRRO\nYYROOOOOOOO\nYYOO";

            var topFirstTime = new TimeConverterTopFirst();
            var topSecondTime = new TimeConverterTopSecond();
            var bottomFirstTime = new TimeConverterBottomFirst();
            var bottomSecondTime = new TimeConverterBottomSecond();
            var yellowLampGen = new TimeConverterYellowLamp();

            var clock = new BerlinClock.Classes.BerlinClock(topFirstTime,
                topSecondTime, bottomFirstTime, bottomSecondTime, yellowLampGen);

            var result = clock.Generate(hours, minutes, seconds);
            Assert.AreEqual(result, expectedResult);
        }
        public void WhenTheTimeIs_JustBeforeMidnight()
        {
            int hours = 23;
            int minutes = 59;
            int seconds = 59;
            string expectedResult = "O\nRRRR\nRRRO\nYYRYYRYYRYY\nYYYY";

            var topFirstTime = new TimeConverterTopFirst();
            var topSecondTime = new TimeConverterTopSecond();
            var bottomFirstTime = new TimeConverterBottomFirst();
            var bottomSecondTime = new TimeConverterBottomSecond();
            var yellowLampGen = new TimeConverterYellowLamp();

            var clock = new BerlinClock.Classes.BerlinClock(topFirstTime,
                topSecondTime, bottomFirstTime, bottomSecondTime, yellowLampGen);

            var result = clock.Generate(hours, minutes, seconds);
            Assert.AreEqual(result, expectedResult);
        }
コード例 #7
0
 public void Initialise()
 {
     berlinClock = new BerlinClock.Classes.BerlinClock(new TimeParser());
 }
コード例 #8
0
ファイル: TimeConverter.cs プロジェクト: Caris55/BerlinClock
        public string convertTime(string aTime)
        {
            var berlinClock = new Classes.BerlinClock(aTime);

            return(berlinClock.ToString());
        }