示例#1
0
            public void WhenDirectoryHasDirectories_ThenAssertTrue()
            {
                BaseDir.CreateDirectory("Test-ContainsDir1");
                BaseDir.CreateDirectory("Test-ContainsDir2");

                Assert.DoesNotThrow(() => AssertDir.ContainsDirectories(ExistingDirectory, 2));
            }
示例#2
0
            public void WhenDirectoryHasFiles_ThenAssertTrue()
            {
                BaseDir.CreateFile("Test-ContainsFiles1.txt");
                BaseDir.CreateFile("Test-ContainsFiles2.txt");

                Assert.DoesNotThrow(() => AssertDir.ContainsFiles(ExistingDirectory, 2));
            }
示例#3
0
            public void WhenDirectoryIsNotEmpty_ThenDoNotDelete()
            {
                FileBuilder.InFileSystem.WithPath(Path.Combine(WorkingDir, "Test1.txt")).Build();

                var sut = CreateSut();

                sut.DeleteIfEmpty();

                AssertDir.ContainsFiles(sut, 1);
            }
示例#4
0
            public void WhenDirectoryDoesNotExist_ThenCreateDirectoy()
            {
                var path = GetAbsolutePath("CD1");

                _sut = CreateSut(path);

                _sut.CreateDirectory();

                AssertDir.Exists(path);
            }
示例#5
0
            public void WhenDirectoryIsEmpty_ThenDelete()
            {
                var sut = CreateSut();

                sut.Empty();

                sut.DeleteIfEmpty();

                AssertDir.NotExists(sut);
            }
示例#6
0
            public void WhenDirectoryHasParentDirectoryThatDoesNotExist_ThenCreateDirectorysRecursively()
            {
                var path = GetAbsolutePath(@"CDx\CDy\CDz");

                _sut = CreateSut(path);

                _sut.CreateDirectory();

                AssertDir.Exists(path);
            }
示例#7
0
            public void WhenThereAreDirectories_ThenDeleteAllDirectories()
            {
                DirectoryBuilder.InFileSystem.WithPath(GetAbsolutePath("DirTest1")).Build();
                DirectoryBuilder.InFileSystem.WithPath(GetAbsolutePath("DirTest2")).Build();

                var sut = CreateSut();

                sut.DeleteDirectories();

                AssertDir.HasNoDirectories(sut);
            }
示例#8
0
            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);
            }
示例#9
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);
            }
示例#10
0
            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);
            }
示例#11
0
            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);
            }
示例#12
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);
            }
示例#13
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);
            }
示例#14
0
            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);
            }
示例#15
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);
            }
示例#16
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);
            }
示例#17
0
            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);
            }
示例#18
0
            public void WhenDirectoryHasDirectories_ThenAssertFalse()
            {
                BaseDir.CreateDirectory("Test-HasNoDirectories");

                Assert.Throws <AssertionException>(() => AssertDir.HasNoDirectories(ExistingDirectory));
            }
示例#19
0
 public void WhenDirectoryHasNoDirectories_ThenAssertTrue()
 {
     Assert.DoesNotThrow(() => AssertDir.HasNoDirectories(ExistingDirectory));
 }
示例#20
0
            public void WhenDirectoryHasFiles_ThenAssertFalse()
            {
                BaseDir.CreateFile("Test-HasNoFiles.txt");

                Assert.Throws <AssertionException>(() => AssertDir.HasNoFiles(ExistingDirectory));
            }
示例#21
0
            public void WhenDirectoryHasFiles_ThenAssertFalse()
            {
                BaseDir.CreateFile(Path.Combine(ExistingDirectory.FullName, "TestFile1.txt"));

                Assert.Throws <AssertionException>(() => AssertDir.IsEmpty(ExistingDirectory));
            }
示例#22
0
 public void WhenDirectoryIsEmpty_ThenAssertTrue()
 {
     Assert.DoesNotThrow(() => AssertDir.IsEmpty(ExistingDirectory));
 }
示例#23
0
 public void WhenDirectoryDoesNotExist_ThenAssertTrue()
 {
     Assert.DoesNotThrow(() => AssertDir.NotExists(DoesNotExistDirectory));
 }
示例#24
0
 public void WhenDirectoryExists_ThenAssertFalse()
 {
     Assert.Throws <AssertionException>(() => AssertDir.NotExists(ExistingDirectory));
 }
示例#25
0
 public void WhenDirectoryExists_ThenAssertTrue()
 {
     Assert.DoesNotThrow(() => AssertDir.Exists(ExistingDirectory));
 }
示例#26
0
 public void WhenDirectoryDoesNotExist_ThenAssertFalse()
 {
     Assert.Throws <AssertionException>(() => AssertDir.Exists(DoesNotExistDirectory));
 }