Example #1
0
        public void GuardAndMostMinutesAsleepMultiplied()
        {
            var day4          = new Day4.Day4();
            var data          = day4.MapDataToShifts(GetExampleData());
            var guardsMinutes = day4.ComputeGuardsSleepyTime(data);

            var actual   = day4.FindGuardMostAsleepAtMinute(guardsMinutes);
            var expected = 10 * 24;

            Assert.AreEqual(expected, actual);
        }
Example #2
0
        public void FindGuardMostFrequentlyAsleepAtSameMinute()
        {
            var day4          = new Day4.Day4();
            var data          = day4.MapDataToShifts(GetExampleData());
            var guardsMinutes = day4.ComputeGuardsSleepyTime(data);

            var actual   = day4.FindMostFrequentlyAsleepAtSameMinute(guardsMinutes);
            var expected = 99 * 45;

            Assert.AreEqual(expected, actual);
        }
Example #3
0
        public void ShiftDataIsComputedGuardSleepyTime()
        {
            var day4 = new Day4.Day4();
            var data = new List <Shift>
            {
                new Shift
                {
                    Action   = Day4.Action.BeginShift,
                    GuardId  = 1,
                    DateTime = new DateTime(2018, 12, 05, 0, 0, 0)
                },
                new Shift
                {
                    Action   = Day4.Action.FallsAsleep,
                    DateTime = new DateTime(2018, 12, 5, 0, 5, 0)
                },
                new Shift
                {
                    Action   = Day4.Action.WakesUp,
                    DateTime = new DateTime(2018, 12, 5, 0, 10, 0)
                }
            };

            var actual   = day4.ComputeGuardsSleepyTime(data);
            var expected = new List <GuardSleepyTime>
            {
                new GuardSleepyTime
                {
                    GuardId      = 1,
                    MinuteAmount = new Dictionary <int, int>(),
                    TotalMinutes = 5
                }
            };

            var expectedDict = expected.Single().MinuteAmount;

            expectedDict.Add(5, 1);
            expectedDict.Add(6, 1);
            expectedDict.Add(7, 1);
            expectedDict.Add(8, 1);
            expectedDict.Add(9, 1);
            expectedDict.Add(10, 1);

            Assert.IsTrue(actual.Single().GuardId == expected.Single().GuardId);
            Assert.IsTrue(actual.Single().TotalMinutes == expected.Single().TotalMinutes);
            CollectionAssert.AreEqual(expectedDict, actual.Single().MinuteAmount);
        }