コード例 #1
0
        public void ZeroAsSetSecondsTurnsOnOnlyTopDiode()
        {
            BerlinClockTimeRepresentation timeRepresentation = new BerlinClockTimeRepresentation();

            timeRepresentation.SetSeconds(0);

            Assert.IsTrue(timeRepresentation.FirstRow.All(x => !x.IsOn));
            Assert.IsTrue(timeRepresentation.SecondRow.All(x => !x.IsOn));
            Assert.IsTrue(timeRepresentation.ThirdRow.All(x => !x.IsOn));
            Assert.IsTrue(timeRepresentation.ForthRow.All(x => !x.IsOn));
            Assert.IsTrue(timeRepresentation.TopDiode.IsOn);
        }
コード例 #2
0
        public void FiftyNineAsSetSecondsTurnsOnNoneOfDiodes()
        {
            BerlinClockTimeRepresentation timeRepresentation = new BerlinClockTimeRepresentation();

            timeRepresentation.SetSeconds(59);

            Assert.IsTrue(timeRepresentation.FirstRow.All(x => !x.IsOn));
            Assert.IsTrue(timeRepresentation.SecondRow.All(x => !x.IsOn));
            Assert.IsTrue(timeRepresentation.ThirdRow.All(x => !x.IsOn));
            Assert.IsTrue(timeRepresentation.ForthRow.All(x => !x.IsOn));
            Assert.IsFalse(timeRepresentation.TopDiode.IsOn);
        }
コード例 #3
0
        public BerlinClockTimeRepresentation RepresentTime(TimeSpan timeInput)
        {
            if (timeInput.TotalHours > 24.0)
            {
                throw new ArgumentException(string.Format("Hours cannot exeed 24. Got {0}", timeInput));
            }

            BerlinClockTimeRepresentation timeRepresentation = berlinClockFactory.BuildNew();

            timeRepresentation.ResetClock();
            if (timeInput == OneFullDay)
            {
                timeRepresentation.SetHours(24);
            }
            else
            {
                timeRepresentation.SetHours(timeInput.Hours);
            }

            timeRepresentation.SetMinutes(timeInput.Minutes);
            timeRepresentation.SetSeconds(timeInput.Seconds);
            return(timeRepresentation);
        }