public void TwentyFourHoursAsSetHoursInputTurnOnAllDiodesOnFirstAndSecondRow() { BerlinClockTimeRepresentation timeRepresentation = new BerlinClockTimeRepresentation(); timeRepresentation.SetHours(24); 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)); }
public void ZeroHoursAsSetHoursInputTurnOnNoDiodes() { BerlinClockTimeRepresentation timeRepresentation = new BerlinClockTimeRepresentation(); timeRepresentation.SetHours(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); }
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); }
public void FiveHoursAsSetHoursInputTurnOnOneDiodeOnFirstRow() { BerlinClockTimeRepresentation timeRepresentation = new BerlinClockTimeRepresentation(); timeRepresentation.SetHours(5); for (int i = 0; i < 4; i++) { if (i == 0) { Assert.IsTrue(timeRepresentation.FirstRow[i].IsOn); } else { Assert.IsFalse(timeRepresentation.FirstRow[i].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)); }