コード例 #1
0
ファイル: CShell.Tests.cs プロジェクト: tomlm/CShell
        public void Test_move()
        {
            Environment.CurrentDirectory = testFolder;

            var shell = new CShell();

            shell.cd(testFolder);
            File.WriteAllText(Path.Combine(shell.CurrentFolder.FullName, "test.txt"), "test");

            shell.move("test.txt", subFolder);
            string path2 = Path.Combine(subFolder, "test.txt");

            Assert.IsTrue(File.Exists(path2));

            shell.cd(subFolder);
            shell.move("test.txt", Path.Combine("..", "test2.txt"));
            string path3 = Path.Combine(testFolder, "test2.txt");

            Assert.IsTrue(File.Exists(path3));

            File.Delete(Path.Combine(testFolder, "test2.txt"));
        }
コード例 #2
0
ファイル: CShell.Tests.cs プロジェクト: tomlm/CShell
        public void Test_MoveCopyFolder()
        {
            Environment.CurrentDirectory = testFolder;

            var shell = new CShell();

            shell.cd(testFolder);
            if (Directory.Exists(shell.ResolvePath("test2")))
            {
                shell.rd("test2", recursive: true);
            }

            shell.copy("subfolder", "test2");
            Assert.IsTrue(File.Exists(Path.Combine(testFolder, "test2", "TestC.txt")));
            Assert.IsTrue(File.Exists(Path.Combine(testFolder, "test2", "subfolder2", "TestE.txt")));
            shell.move("test2", "test3");
            Assert.IsTrue(!Directory.Exists("test2"));
            Assert.IsTrue(File.Exists(Path.Combine(testFolder, "test3", "TestC.txt")));
            Assert.IsTrue(File.Exists(Path.Combine(testFolder, "test3", "subfolder2", "TestE.txt")));

            shell.rd("test3", recursive: true);
        }