Example #1
0
        public void ChangeDirectory()
        {
            var fileSystem = new Models.FileSystem();

            fileSystem.CreateDirectory("/directory");
            fileSystem.CreateDirectory("/directory/testDirectory");

            Assert.AreEqual("/", fileSystem.CurrentDirectoryPath);

            fileSystem.ChangeDirectory("/directory");

            Assert.AreEqual("/directory", fileSystem.CurrentDirectoryPath);

            fileSystem.ChangeDirectory("testDirectory");

            Assert.AreEqual("/directory/testDirectory", fileSystem.CurrentDirectoryPath);

            fileSystem.ChangeDirectory("..");

            Assert.AreEqual("/directory", fileSystem.CurrentDirectoryPath);

            fileSystem.ChangeDirectory("../directory/testDirectory");

            Assert.AreEqual("/directory/testDirectory", fileSystem.CurrentDirectoryPath);

            fileSystem.ChangeDirectory("/");

            Assert.AreEqual("/", fileSystem.CurrentDirectoryPath);
        }
Example #2
0
        public void TryNavigateToInvalidDirectory()
        {
            var fileSystem = new Models.FileSystem();

            fileSystem.CreateDirectory("/directory");
            fileSystem.CreateDirectory("/directory/testDirectory");

            fileSystem.ChangeDirectory("/directory1");
        }
Example #3
0
 /// <summary>
 /// Executes the change directory command.
 /// </summary>
 /// <param name="fileSystem">The file system on which the command is going to be executed.</param>
 public override void Execute(Models.FileSystem fileSystem)
 {
     try
     {
         fileSystem.ChangeDirectory(Path);
     }
     catch (InvalidOperationException exception)
     {
         Console.WriteLine(exception.Message);
     }
 }