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(); }
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(); }
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); }
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); }