Exemplo n.º 1
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();
        }
Exemplo n.º 2
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();
        }
Exemplo n.º 3
0
        public int GetTreesHit(List <Row> rows, int rightVel, int downVel)
        {
            var checksForTrees = new ChecksForTrees();
            int treesHit       = 0;
            int currentRow     = 1;
            int currentColumn  = 1;

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

            return(treesHit);
        }
Exemplo n.º 4
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);
        }