public void WhenDirectoryIsEmpty_ThenDelete() { var sut = CreateSut(); sut.Empty(); sut.DeleteIfEmpty(); AssertDir.NotExists(sut); }
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); }
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); }
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); }
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); }
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); }
public void WhenDirectoryDoesNotExist_ThenAssertTrue() { Assert.DoesNotThrow(() => AssertDir.NotExists(DoesNotExistDirectory)); }
public void WhenDirectoryExists_ThenAssertFalse() { Assert.Throws <AssertionException>(() => AssertDir.NotExists(ExistingDirectory)); }