public void ShouldCallLineCounterWithContentsOfFile(string filePath, string sourceCode) { var fileSystem = new FakeFileSystemAccessBuilder() .WithReadAllTextReturning(filePath, sourceCode) .Build(); var counter = new FakeLineCounterBuilder() .Build(); var sut = CreateSut(fileSystem: fileSystem, lineCounter: counter); sut.Count(filePath); FakeLineCounterBuilder.VerifyCountWasCalledOn(counter, sourceCode); }
public void GivenPathWithKnownContents_ShouldReturnExpectedLines(string expectedPath, string sourceCode, int expectedLineCount) { var fileSystem = new FakeFileSystemAccessBuilder() .WithReadAllTextReturning(expectedPath, sourceCode) .Build(); var counter = new FakeLineCounterBuilder() .WithCountReturning(sourceCode, expectedLineCount) .Build(); var sut = CreateSut(fileSystem: fileSystem, lineCounter: counter); var actual = sut.Count(expectedPath); Assert.AreEqual(expectedLineCount, actual); }