예제 #1
0
        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());
        }
예제 #2
0
        public void ListDirFromArg_WhenPrintRootDirNameTrue_PrintsRootDir()
        {
            MDirectoryInfo.AllInstances.GetFileSystemInfos = x => new FileSystemInfo[] {};

            var output = new StringWriter();

            var ls = new TestableListFileSystem(output, @"L:\baz", string.Empty) { ShouldPrintRootDirName = true };

            ls.TestListDirFromArg();

            Assert.AreEqual("L:\\baz:\r\n", output.ToString());
        }
예제 #3
0
        public void ListDirFromArg_WhenPrintRootDirNameTrue_PrintsRootDir()
        {
            MDirectoryInfo.AllInstances.GetFileSystemInfos = x => new FileSystemInfo[] {};

            var output = new StringWriter();

            var ls = new TestableListFileSystem(output, @"L:\baz", string.Empty)
            {
                ShouldPrintRootDirName = true
            };

            ls.TestListDirFromArg();

            Assert.AreEqual("L:\\baz:\r\n", output.ToString());
        }
예제 #4
0
        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());
        }