public void ListDir_WhenAbsNonEmptyDirIsListedRecursive_ContentsAndAbsDirShownAndRecursionContinues() { var pathLBazStub = new MDirectoryInfo(); new MFileSystemInfo(pathLBazStub) { FullNameGet = () => @"L:\baz" }; var pathLBazFooStubContents = new FileSystemInfo[] { }; var pathLBazStubContents = new FileSystemInfo[] { new MFileInfo() { NameGet = () => @"a.txt" }, new MFileInfo() { NameGet = () => @"b.txt" }, new MFileInfo() { NameGet = () => @"c.txt" }, new MDirectoryInfo() { NameGet = () => @"foo", GetFileSystemInfos = () => pathLBazFooStubContents } }; new MFileSystemInfo(pathLBazStubContents[3]) { AttributesGet = () => FileAttributes.Directory, FullNameGet = () => @"L:\baz\foo" }; new MFileSystemInfo(pathLBazStubContents[0]) { AttributesGet = () => FileAttributes.Normal }; new MFileSystemInfo(pathLBazStubContents[1]) { AttributesGet = () => FileAttributes.Normal }; new MFileSystemInfo(pathLBazStubContents[2]) { AttributesGet = () => FileAttributes.Normal }; MDirectoryInfo.AllInstances.GetFileSystemInfos = (x) => new FileSystemInfo[0]; pathLBazStub.GetFileSystemInfos = () => pathLBazStubContents; var outputString = new StringWriter(); new TestableListFileSystem(output: outputString, dirSuffix: @"L:\baz") { ShouldRecurseDirs = true }.TestListDir(pathLBazStub); Assert.AreEqual("a.txt\r\nb.txt\r\nc.txt\r\nfoo\r\n\r\nL:\\baz\\foo:\r\n", outputString.ToString()); }
public void ListDir_NonEmptyDirectory_ContentsListed(string dirPath) { var output = new StringWriter(); var ls = new TestableListFileSystem(output, string.Empty); var pathLBazStub = new MDirectoryInfo(); new MFileSystemInfo(pathLBazStub) { FullNameGet = () => dirPath }; var pathLBazStubContents = new FileSystemInfo[] { new MFileInfo() { NameGet = () => @"a.txt" }, new MFileInfo() { NameGet = () => @"b.txt" }, new MFileInfo() { NameGet = () => @"c.txt" } }; pathLBazStub.GetFileSystemInfos = () => pathLBazStubContents; ls.TestListDir(pathLBazStub); Assert.AreEqual("a.txt\r\nb.txt\r\nc.txt\r\n", output.ToString()); }