Esempio n. 1
0
        public void RemoveContentFilesFromDifferentDirectories()
        {
            var fileSystem = new Models.FileSystem();

            fileSystem.CreateDirectory("/directory");
            fileSystem.CreateDirectory("/directory/directory1");
            if (fileSystem.TryGetFile("/directory", out var file) && file is Directory directory)
            {
                if (fileSystem.TryGetFile("/directory/directory1", out var file1) && file1 is Directory directory1)
                {
                    directory.AddChild(new ContentFile("/directory/file1", "test", directory));
                    directory1.AddChild(new ContentFile("/directory/directory1/file2", "test", directory1));

                    var paths = new[] { "/directory/file1", "/directory/directory1/file2" };

                    Assert.IsTrue(2 == directory.GetChildren().Count());
                    Assert.IsTrue(1 == directory1.GetChildren().Count());

                    fileSystem.RemoveContentFiles(paths);

                    Assert.IsTrue(1 == directory.GetChildren().Count());
                    Assert.IsTrue(!directory1.GetChildren().Any());
                }
                else
                {
                    Assert.Fail();
                }
            }
            else
            {
                Assert.Fail();
            }
        }
Esempio n. 2
0
        public void TryRemoveDirectoryWithRemoveContentFileFunction()
        {
            var fileSystem = new Models.FileSystem();

            fileSystem.CreateDirectory("/directory");
            var paths = new[] { "/directory" };

            fileSystem.RemoveContentFiles(paths);
        }
Esempio n. 3
0
 /// <summary>
 /// Executes the remove 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.RemoveContentFiles(Paths);
     }
     catch (InvalidOperationException invalidOperationException)
     {
         Console.WriteLine(invalidOperationException.Message);
     }
 }
Esempio n. 4
0
        public void TryRemoveOneDirectoryOneContentFileWithRemoveContentFileFunction()
        {
            var fileSystem = new Models.FileSystem();

            fileSystem.CreateDirectory("/directory");

            if (fileSystem.TryGetFile("/directory", out var file) && file is Directory directory)
            {
                directory.AddChild(new ContentFile("/file1", "test", directory));

                var paths = new[] { "/file1", "/directory" };

                fileSystem.RemoveContentFiles(paths);
            }
            else
            {
                Assert.Fail();
            }
        }
Esempio n. 5
0
        public void TryRemoveMissingContentFile()
        {
            var fileSystem = new Models.FileSystem();

            fileSystem.CreateDirectory("/directory");

            if (fileSystem.TryGetFile("/directory", out var file) && file is Directory directory)
            {
                directory.AddChild(new ContentFile("/directory/file1", "test", directory));

                var paths = new[] { "/directory/file1", "/directory/file2" };

                Assert.IsTrue(1 == directory.GetChildren().Count());

                fileSystem.RemoveContentFiles(paths);
            }
            else
            {
                Assert.Fail();
            }
        }