forked from baronfel/FAKE
Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
33 changed files
with
521 additions
and
970 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System.IO; | ||
using Machine.Specifications; | ||
|
||
namespace Test.FAKECore.FileHandling | ||
{ | ||
public class when_cleaning_empty_directory_after_creating_test_structure : BaseFunctions | ||
{ | ||
Establish context = CreateTestDirStructure; | ||
|
||
Because of = () => CleanDir(TestData.TestDir); | ||
|
||
It should_cleaned_all_dirs = () => AllDirectories().ShouldBeEmpty(); | ||
It should_cleaned_all_files = () => AllFiles().ShouldBeEmpty(); | ||
It should_still_exist = () => new DirectoryInfo(TestData.TestDir).Exists.ShouldBeTrue(); | ||
} | ||
|
||
public class when_cleaning_directory_after_creating_test_structure : BaseFunctions | ||
{ | ||
Establish context = CreateTestFileStructure; | ||
|
||
Because of = () => CleanDir(TestData.TestDir); | ||
|
||
It should_be_writeable = | ||
() => new DirectoryInfo(TestData.TestDir).Attributes.ShouldEqual(FileAttributes.Directory); | ||
|
||
It should_cleaned_all_dirs = () => AllDirectories().ShouldBeEmpty(); | ||
It should_cleaned_all_files = () => AllFiles().ShouldBeEmpty(); | ||
It should_still_exist = () => new DirectoryInfo(TestData.TestDir).Exists.ShouldBeTrue(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.IO; | ||
using Fake; | ||
using Machine.Specifications; | ||
|
||
namespace Test.FAKECore.FileHandling | ||
{ | ||
public class when_copying_directory_with_subfolders_but_without_filter : BaseFunctions | ||
{ | ||
Establish context = CreateTestFileStructure; | ||
|
||
Because of = () => FileHelper.CopyDir(Target, TestData.SubDir7, AllFilesFunction); | ||
|
||
It should_have_copied_all_files = | ||
() => Directory.GetFiles(Target, "*.*", SearchOption.AllDirectories).Length.ShouldEqual(6); | ||
|
||
It should_have_copied_the_subfolder = | ||
() => Directory.GetDirectories(Target, "*", SearchOption.AllDirectories).Length.ShouldEqual(1); | ||
|
||
private static readonly string Target = string.Format("{0}\\CopyTo", TestData.TestDir); | ||
} | ||
|
||
public class when_copying_directory_but_without_filter : BaseFunctions | ||
{ | ||
Establish context = CreateTestFileStructure; | ||
|
||
Because of = () => FileHelper.CopyDir(Target, TestData.SubDir1, AllFilesFunction); | ||
|
||
It should_have_copied_all_files = | ||
() => Directory.GetFiles(Target, "*.*", SearchOption.AllDirectories).Length.ShouldEqual(3); | ||
|
||
It should_not_have_copied_a_subfolder = | ||
() => Directory.GetDirectories(Target, "*", SearchOption.AllDirectories).ShouldBeEmpty(); | ||
|
||
private static readonly string Target = string.Format("{0}\\CopyTo", TestData.TestDir); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System.IO; | ||
using Fake; | ||
using Machine.Specifications; | ||
|
||
namespace Test.FAKECore.FileHandling | ||
{ | ||
public class when_comparing_nonidentical_files | ||
{ | ||
private static readonly FileInfo File1 = new FileInfo(@"TestData\AllObjects.txt"); | ||
private static readonly FileInfo File2 = new FileInfo(@"TestData\AllObjects_2.txt"); | ||
|
||
It should_not_be_identical = () => FileHelper.FilesAreEqual(File1, File2).ShouldBeFalse(); | ||
} | ||
|
||
public class when_comparing_identical_files | ||
{ | ||
private static readonly FileInfo File1 = new FileInfo(@"TestData\AllObjects.txt"); | ||
private static readonly FileInfo File2 = new FileInfo(@"TestData\AllObjects.txt"); | ||
|
||
It should_be_identical = () => FileHelper.FilesAreEqual(File1, File2).ShouldBeTrue(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using System.Linq; | ||
using Fake; | ||
using Machine.Specifications; | ||
|
||
namespace Test.FAKECore.FileHandling | ||
{ | ||
public class when_creating_some_directories_and_scanning_them : BaseFunctions | ||
{ | ||
Establish context = CreateTestDirStructure; | ||
|
||
It should_find_the_test_dir = () => Scan("Test").First().ShouldEqual(TestData.TestDir); | ||
It should_find_only_the_test_dir = () => Scan("Test").Count.ShouldEqual(1); | ||
It should_find_Dir2 = () => ScanCount("**/Dir2").ShouldEqual(1); | ||
It should_find_Sub1_in_subfolder = () => ScanCount("**/**/Sub1").ShouldEqual(6); | ||
It should_find_Sub1 = () => ScanCount("**/Sub1").ShouldEqual(6); | ||
It should_find_Sub1_in_sub2 = () => ScanCount("**/Sub2/Sub1").ShouldEqual(1); | ||
It should_find_Sub2 = () => ScanCount("**/Sub2").ShouldEqual(2); | ||
It should_find_test_directory_in_base_directory = () => Scan(@"Test").First().ShouldEqual(TestData.TestDir); | ||
} | ||
|
||
public class when_creating_some_files_and_scanning_them : BaseFunctions | ||
{ | ||
Establish context = CreateTestFileStructure; | ||
|
||
It should_find_file1 = () => ScanCount("**/file1.nav").ShouldEqual(3); | ||
It should_find_file1_with_every_extension = () => ScanCount("**/file1.*").ShouldEqual(5); | ||
It should_find_file_x = () => ScanCount("**/file?.n??").ShouldEqual(11); | ||
It should_find_file_x_in_subfolder = () => ScanCount("**/Sub1/**/file*.*").ShouldEqual(6); | ||
It should_find_every_nav_file_in_every_folder = () => ScanCount("**/*.nav").ShouldEqual(7); | ||
It should_not_find_a_nav_file_in_root = () => ScanCount("*.nav").ShouldEqual(0); | ||
It should_find_all_files_in_test_folder = () => ScanCount("Test/*.*").ShouldEqual(5); | ||
} | ||
|
||
public class when_creating_some_files_and_scanning_them_with_concrete_path : BaseFunctions | ||
{ | ||
Establish context = CreateTestFileStructure; | ||
|
||
It should_find_file1 = () => ScanCount(FileSetHelper.DefaultBaseDir + "/**/file1.nav").ShouldEqual(3); | ||
It should_find_file1_with_every_extension = () => ScanCount(FileSetHelper.DefaultBaseDir + "/**/file1.*").ShouldEqual(5); | ||
It should_find_file_x = () => ScanCount(FileSetHelper.DefaultBaseDir + "/**/file?.n??").ShouldEqual(11); | ||
It should_find_file_x_in_subfolder = () => ScanCount(FileSetHelper.DefaultBaseDir + "/Test/**/Sub1/**/file*.*").ShouldEqual(6); | ||
It should_find_every_nav_file_in_every_folder = () => ScanCount(FileSetHelper.DefaultBaseDir + "/Test/**/*.nav").ShouldEqual(7); | ||
It should_not_find_a_nav_file_in_root = () => ScanCount(FileSetHelper.DefaultBaseDir + "/*.nav").ShouldEqual(0); | ||
It should_find_all_files_in_test_folder = () => ScanCount(FileSetHelper.DefaultBaseDir + "/Test/*.*").ShouldEqual(5); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.