Exemple #1
0
        public void Run_WhenAbsPathIsFile_AbsNameIsListed()
        {
            var output = new StringWriter();

            var ls = new ListFileSystem(output, @"L:\foo.txt");

            MFile.GetAttributesString = (fileName) => FileAttributes.Normal;

            ls.Run();

            Assert.AreEqual("L:\\foo.txt\r\n", output.ToString());
        }
Exemple #2
0
        public void List_WhenPathIsTooLong_DisplaysError()
        {
            var output = new StringWriter();

            const string targetFileName = @"L:\thisistoolong";

            var ls = new ListFileSystem(output, targetFileName);

            MFile.GetAttributesString = (fileName) => { throw new PathTooLongException(); };

            ls.Run();

            Assert.AreEqual("ls: cannot access L:\\thisistoolong: No such file or directory\r\n", output.ToString());
        }
Exemple #3
0
        public void List_WhenFileDoesNotExist_DisplaysError()
        {
            var output = new StringWriter();

            const string targetFileName = @"L:\foo.txt";

            var ls = new ListFileSystem(output, targetFileName);

            MFile.GetAttributesString = (fileName) => { throw new FileNotFoundException(); };

            ls.Run();

            Assert.AreEqual("ls: cannot access L:\\foo.txt: No such file or directory\r\n", output.ToString());
        }
Exemple #4
0
        public void List_WhenRelDirDoesNotExist_DisplaysError()
        {
            StringWriter output = new StringWriter();

            const string targetFileName = @"bar";

            ListFileSystem ls = new ListFileSystem(output, targetFileName);

            MFile.GetAttributesString = (fileName) => { throw new DirectoryNotFoundException(); };

            ls.Run();

            Assert.AreEqual("ls: cannot access bar: No such file or directory\r\n", output.ToString());
        }
Exemple #5
0
        public void ListFileSystem_constructs_notnull()
        {
            var ls = new ListFileSystem(new StringWriter(), string.Empty);

            Assert.IsNotNull(ls);
        }