public void ShiftInfoTest() { Day04.ShiftInfo shiftInfo = null; foreach (var rawRecord in Common.ParseStringArray(inputDay04Example1)) { var record = new Day04.Record(rawRecord); if (record.Type == Day04.Record.RecordType.ShiftStart) { if (shiftInfo == null) { shiftInfo = new Day04.ShiftInfo(record); } else { break; } } else { shiftInfo.AddRecord(record); } } shiftInfo.CalculateTimeAsleep(); Assert.AreEqual(45, shiftInfo.MinutesAsleep); CollectionAssert.AreEqual(new bool[] { false, false, false, false, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, false, false, false, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, false, false, false, false }, shiftInfo.IsAsleep); }
public void RecordInitializeTest() { var record = new Day04.Record("[1518-11-03 00:05] Guard #10 begins shift"); Assert.AreEqual(new DateTime(1518, 11, 03, 00, 05, 00), record.Time); Assert.AreEqual(Day04.Record.RecordType.ShiftStart, record.Type); Assert.AreEqual(10, record.ID); // Fall Asleep Assert.AreEqual(Day04.Record.RecordType.FallAsleep, new Day04.Record("[1518-11-03 00:24] falls asleep").Type); // Wake up Assert.AreEqual(Day04.Record.RecordType.WakeUp, new Day04.Record("[1518-11-03 00:29] wakes up").Type); }
public void RecordInvalidEventTest() { var record = new Day04.Record("[1518-11-03 00:05] Unknown event"); }