public void WhenDirectoryHasDirectories_ThenAssertTrue() { BaseDir.CreateDirectory("Test-ContainsDir1"); BaseDir.CreateDirectory("Test-ContainsDir2"); Assert.DoesNotThrow(() => AssertDir.ContainsDirectories(ExistingDirectory, 2)); }
public void WhenDirectoryHasFiles_ThenAssertTrue() { BaseDir.CreateFile("Test-ContainsFiles1.txt"); BaseDir.CreateFile("Test-ContainsFiles2.txt"); Assert.DoesNotThrow(() => AssertDir.ContainsFiles(ExistingDirectory, 2)); }
public void WhenDirectoryIsNotEmpty_ThenDoNotDelete() { FileBuilder.InFileSystem.WithPath(Path.Combine(WorkingDir, "Test1.txt")).Build(); var sut = CreateSut(); sut.DeleteIfEmpty(); AssertDir.ContainsFiles(sut, 1); }
public void WhenDirectoryDoesNotExist_ThenCreateDirectoy() { var path = GetAbsolutePath("CD1"); _sut = CreateSut(path); _sut.CreateDirectory(); AssertDir.Exists(path); }
public void WhenDirectoryIsEmpty_ThenDelete() { var sut = CreateSut(); sut.Empty(); sut.DeleteIfEmpty(); AssertDir.NotExists(sut); }
public void WhenDirectoryHasParentDirectoryThatDoesNotExist_ThenCreateDirectorysRecursively() { var path = GetAbsolutePath(@"CDx\CDy\CDz"); _sut = CreateSut(path); _sut.CreateDirectory(); AssertDir.Exists(path); }
public void WhenThereAreDirectories_ThenDeleteAllDirectories() { DirectoryBuilder.InFileSystem.WithPath(GetAbsolutePath("DirTest1")).Build(); DirectoryBuilder.InFileSystem.WithPath(GetAbsolutePath("DirTest2")).Build(); var sut = CreateSut(); sut.DeleteDirectories(); AssertDir.HasNoDirectories(sut); }
public void WhenThereAreTwoFiles_ThenDeleteAllFiles() { FileBuilder.InFileSystem.WithPath(GetAbsolutePath("Test1.txt")).Build(); FileBuilder.InFileSystem.WithPath(GetAbsolutePath("Test2.txt")).Build(); var sut = CreateSut(); sut.DeleteFiles(); AssertDir.HasNoFiles(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 WhenExtensionIsEmpty_ThenDeleteOnlyFilesWithNoExtension() { FileBuilder.InFileSystem.WithPath(GetAbsolutePath("Test1")).Build(); FileBuilder.InFileSystem.WithPath(GetAbsolutePath("Test2")).Build(); FileBuilder.InFileSystem.WithPath(GetAbsolutePath("Test3.log")).Build(); var sut = CreateSut(); sut.DeleteFiles(""); AssertDir.ContainsFiles(sut, 1); }
public void WhenExtensionSpecified_ThenDeleteOnlyFilesWithExtension() { FileBuilder.InFileSystem.WithPath(GetAbsolutePath("Test1.txt")).Build(); FileBuilder.InFileSystem.WithPath(GetAbsolutePath("Test2.txt")).Build(); FileBuilder.InFileSystem.WithPath(GetAbsolutePath("Test3.log")).Build(); var sut = CreateSut(); sut.DeleteFiles("txt"); AssertDir.ContainsFiles(sut, 1); }
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 WhenThereAreFilesAndDirectories_ThenDeleteAllFilesAndDirectories() { 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.Empty(); AssertDir.IsEmpty(sut); }
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 WhenContainsFilesNotOnExceptList_ThenDeleteFiles() { FileBuilder.InFileSystem.WithPath(GetAbsolutePath("Test1.txt")).Build(); FileBuilder.InFileSystem.WithPath(GetAbsolutePath("Test2.txt")).Build(); FileBuilder.InFileSystem.WithPath(GetAbsolutePath("Test3.txt")).Build(); FileBuilder.InFileSystem.WithPath(GetAbsolutePath("Test4.txt")).Build(); FileBuilder.InFileSystem.WithPath(GetAbsolutePath("Test5.txt")).Build(); var testDir = DirectoryBuilder.InFileSystem.WithPath(GetAbsolutePath("DirTest1")).Build(); FileBuilder.InFileSystem.WithPath(GetAbsolutePath(@"DirTest1\Test1.txt")).Build(); FileBuilder.InFileSystem.WithPath(GetAbsolutePath(@"DirTest1\Test3.txt")).Build(); var sut = CreateSut(); sut.DeleteFilesExcept(new List <string> { "Test1.txt", "Test2.txt" }, true); AssertDir.ContainsFiles(sut, 2); AssertDir.ContainsFiles(testDir, 1); }
public void WhenDirectoryHasDirectories_ThenAssertFalse() { BaseDir.CreateDirectory("Test-HasNoDirectories"); Assert.Throws <AssertionException>(() => AssertDir.HasNoDirectories(ExistingDirectory)); }
public void WhenDirectoryHasNoDirectories_ThenAssertTrue() { Assert.DoesNotThrow(() => AssertDir.HasNoDirectories(ExistingDirectory)); }
public void WhenDirectoryHasFiles_ThenAssertFalse() { BaseDir.CreateFile("Test-HasNoFiles.txt"); Assert.Throws <AssertionException>(() => AssertDir.HasNoFiles(ExistingDirectory)); }
public void WhenDirectoryHasFiles_ThenAssertFalse() { BaseDir.CreateFile(Path.Combine(ExistingDirectory.FullName, "TestFile1.txt")); Assert.Throws <AssertionException>(() => AssertDir.IsEmpty(ExistingDirectory)); }
public void WhenDirectoryIsEmpty_ThenAssertTrue() { Assert.DoesNotThrow(() => AssertDir.IsEmpty(ExistingDirectory)); }
public void WhenDirectoryDoesNotExist_ThenAssertTrue() { Assert.DoesNotThrow(() => AssertDir.NotExists(DoesNotExistDirectory)); }
public void WhenDirectoryExists_ThenAssertFalse() { Assert.Throws <AssertionException>(() => AssertDir.NotExists(ExistingDirectory)); }
public void WhenDirectoryExists_ThenAssertTrue() { Assert.DoesNotThrow(() => AssertDir.Exists(ExistingDirectory)); }
public void WhenDirectoryDoesNotExist_ThenAssertFalse() { Assert.Throws <AssertionException>(() => AssertDir.Exists(DoesNotExistDirectory)); }