Ejemplo n.º 1
0
            public void WhenDirectoryIsEmpty_ThenDelete()
            {
                var sut = CreateSut();

                sut.Empty();

                sut.DeleteIfEmpty();

                AssertDir.NotExists(sut);
            }
Ejemplo n.º 2
0
            public void WhenCaseInsensitiveMatchInBase_ThenDelete()
            {
                var dirToNotDelete = DirectoryBuilder.InFileSystem.WithPath(Path.Combine(WorkingDir, "dirToNotDelete")).Build();

                var dirToDelete = DirectoryBuilder.InFileSystem.WithPath(Path.Combine(WorkingDir, "DIRtoDELETE")).Build();

                var result = CreateSut().DeleteDirectoriesWithName("dirToDelete");

                Assert.That(result, Is.EqualTo(1));
                AssertDir.NotExists(dirToDelete);
                AssertDir.Exists(dirToNotDelete);
            }
Ejemplo n.º 3
0
            public void WhenMatchesInSubDir_ThenDelete()
            {
                var dirToNotDelete = DirectoryBuilder.InFileSystem.WithPath(Path.Combine(WorkingDir, "dirToNotDelete")).Build();
                var dirToDelete1   = DirectoryBuilder.InFileSystem.WithPath(Path.Combine(WorkingDir, "dirToDelete")).Build();

                var dirToDelete2 = DirectoryBuilder.InFileSystem.WithPath(Path.Combine(dirToNotDelete.FullName, "dirToDelete")).Build();

                var result = CreateSut().DeleteDirectoriesWithName("dirToDelete");

                Assert.That(result, Is.EqualTo(2));
                AssertDir.NotExists(dirToDelete1);
                AssertDir.NotExists(dirToDelete2);
            }
Ejemplo n.º 4
0
            public void WhenMatchingDirHasFiles_ThenDelete()
            {
                DirectoryBuilder.InFileSystem.WithPath(Path.Combine(WorkingDir, "dirToNotDelete")).Build();

                var dirToDelete = DirectoryBuilder.InFileSystem.WithPath(Path.Combine(WorkingDir, "dirToDelete")).Build();

                FileBuilder.InFileSystem.WithPath(Path.Combine(dirToDelete.FullName, "test.txt")).Build();

                var result = CreateSut().DeleteDirectoriesWithName("dirToDelete");

                Assert.That(result, Is.EqualTo(1));
                AssertDir.NotExists(dirToDelete);
            }
Ejemplo n.º 5
0
            public void WhenContainsFilesAndDirectories_ThenDelete()
            {
                DirectoryBuilder.InFileSystem.WithPath(Path.Combine(WorkingDir, "DirTest1")).Build();
                DirectoryBuilder.InFileSystem.WithPath(Path.Combine(WorkingDir, "DirTest2")).Build();

                FileBuilder.InFileSystem.WithPath(Path.Combine(WorkingDir, "Test1.txt")).Build();
                FileBuilder.InFileSystem.WithPath(Path.Combine(WorkingDir, "Test2.txt")).Build();

                var sut = CreateSut();

                sut.DeleteIfExists();

                AssertDir.NotExists(sut);
            }
Ejemplo n.º 6
0
            public void WhenContainsEmptyDirectories_ThenDeleteEmptyDirectories()
            {
                var dirToNotDelete = DirectoryBuilder.InFileSystem.WithPath(Path.Combine(WorkingDir, "dirToNotDelete")).Build();

                var dirToDelete1 = DirectoryBuilder.InFileSystem.WithPath(Path.Combine(WorkingDir, "dirToDelete1")).Build();
                var dirToDelete2 = DirectoryBuilder.InFileSystem.WithPath(Path.Combine(WorkingDir, "dirToDelete2")).Build();

                FileBuilder.InFileSystem.WithPath(Path.Combine(dirToNotDelete.FullName, "test.txt")).Build();

                CreateSut().DeleteEmptyDirectories();

                AssertDir.Exists(dirToNotDelete);
                AssertDir.NotExists(dirToDelete1);
                AssertDir.NotExists(dirToDelete2);
            }
Ejemplo n.º 7
0
 public void WhenDirectoryDoesNotExist_ThenAssertTrue()
 {
     Assert.DoesNotThrow(() => AssertDir.NotExists(DoesNotExistDirectory));
 }
Ejemplo n.º 8
0
 public void WhenDirectoryExists_ThenAssertFalse()
 {
     Assert.Throws <AssertionException>(() => AssertDir.NotExists(ExistingDirectory));
 }