Пример #1
0
        public void GetsRowsFromFile_TestFile_Gets11Rows()
        {
            var        subject = new GetsRowsFromFile();
            List <Row> result  = subject.Get(testFile);

            result.Count.Should().Be(11);
        }
Пример #2
0
        public void SlopeTrip_RealFile_TripDownRowsGetsTheRightNumberOfTrees()
        {
            var subject  = new SlopeTrip();
            var getsRows = new GetsRowsFromFile();
            var rows     = getsRows.Get(realFile);

            subject.GetTreesHit(rows, 3, 1).Should().Be(276);
        }
Пример #3
0
        public void ChecksForTrees_TestFile_FindsTreesAndSpacesInFirstLinePastEndOfPattern()
        {
            var subject  = new ChecksForTrees();
            var getsRows = new GetsRowsFromFile();
            var rows     = getsRows.Get(testFile);

            subject.Check(rows, 1, 12).Should().BeFalse();
            subject.Check(rows, 1, 13).Should().BeFalse();
            subject.Check(rows, 1, 14).Should().BeTrue();
        }
Пример #4
0
        public void ChecksForTrees_TestFile_FindsTreesAndSpacesInSecondLine()
        {
            var subject  = new ChecksForTrees();
            var getsRows = new GetsRowsFromFile();
            var rows     = getsRows.Get(testFile);

            subject.Check(rows, 2, 1).Should().BeTrue();
            subject.Check(rows, 2, 2).Should().BeFalse();
            subject.Check(rows, 2, 3).Should().BeFalse();
        }
Пример #5
0
        public void SlopeTrip_RealFile_TripDownVariousRoutesMultipliesToCorrectNumber()
        {
            var subject         = new SlopeTrip();
            var getsRows        = new GetsRowsFromFile();
            var rows            = getsRows.Get(realFile);
            var treesHitOnTrips = new List <decimal>
            {
                subject.GetTreesHit(rows, 1, 1),
                subject.GetTreesHit(rows, 3, 1),
                subject.GetTreesHit(rows, 5, 1),
                subject.GetTreesHit(rows, 7, 1),
                subject.GetTreesHit(rows, 1, 2)
            };

            treesHitOnTrips.Aggregate((a, x) => a * x).Should().Be(7812180000);
        }
Пример #6
0
        public void ChecksForTrees_TestFile_TripDownRowsGetsTheRightNumberOfTrees()
        {
            var subject       = new ChecksForTrees();
            var getsRows      = new GetsRowsFromFile();
            var rows          = getsRows.Get(testFile);
            int treesHit      = 0;
            int currentRow    = 1;
            int currentColumn = 1;

            while (currentRow <= rows.Count)
            {
                if (subject.Check(rows, currentRow, currentColumn))
                {
                    treesHit++;
                }

                currentRow++;
                currentColumn += 3;
            }

            treesHit.Should().Be(7);
        }