public void ResetClockSetStateOfAllDiodesToOff()
        {
            BerlinClockTimeRepresentation timeRepresentation = new BerlinClockTimeRepresentation();

            foreach (var diode in timeRepresentation.FirstRow.Union(timeRepresentation.SecondRow).Union(timeRepresentation.ThirdRow).Union(timeRepresentation.ForthRow))
            {
                diode.ChangeState();
            }

            timeRepresentation.TopDiode.ChangeState();
            timeRepresentation.ResetClock();

            Assert.IsTrue(timeRepresentation.FirstRow.Union(timeRepresentation.SecondRow).Union(timeRepresentation.ThirdRow).Union(timeRepresentation.ForthRow).All(x => !x.IsOn));
            Assert.IsFalse(timeRepresentation.TopDiode.IsOn);
        }
Пример #2
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);
        }