public void Ctor_Folder_PlacedIntoWindowsTempoFolder()
 {
     using (var temporaryFolder = new TemporaryFolder())
     {
         Assert.That(temporaryFolder.Folder.StartsWith(Path.GetTempPath()), Is.True);
     }
 }
 public void FileName_AfterDispose_GenerateObjectDisposedException()
 {
     var temporaryFolder = new TemporaryFolder();
     Assert.IsNotNull(temporaryFolder.Folder);
     temporaryFolder.Dispose();
     string folder = temporaryFolder.Folder;
     Assert.Fail("expected exception ObjectDisposedException");
 }
示例#3
0
        public void TemporaryFolderSimpleDemo()
        {
            using (TemporaryFolder temporaryFolder = new TemporaryFolder())
            {
                string filePath = Path.Combine(temporaryFolder.Folder, "file1.txt");
                File.WriteAllText(filePath, "[0]: test");
                File.AppendAllText(filePath, "[1]: additional text");

                string allText = File.ReadAllText(filePath);
                Assert.That(allText, Is.EqualTo("[0]: test" + "[1]: additional text"));
            }
        }
 public void Dispose_DeletedFolder()
 {
     string createdTemporaryFolder;
     using (var temporaryFolder = new TemporaryFolder())
     {
         createdTemporaryFolder = temporaryFolder.Folder;
         Directory.Exists(temporaryFolder.Folder);
         File.WriteAllText(Path.Combine(temporaryFolder.Folder, "file.txt"), "test");
         string subFolder = Path.Combine(temporaryFolder.Folder, "subFolder");
         Directory.CreateDirectory(subFolder);
         File.WriteAllText(Path.Combine(subFolder, "file.txt"), "test");
     }
     Assert.That(Directory.Exists(createdTemporaryFolder), Is.False);
 }
        public void FolderComparison_DifferentFilesInFolders_FalseAndListOfDifferentFiles()
        {
            using (var temporaryFolder1 = new TemporaryFolder())
            using (var temporaryFolder2 = new TemporaryFolder())
            {
                temporaryFolder1.CreateFile("test1.txt");
                temporaryFolder1.CreateFile("test2.txt");
                temporaryFolder2.CreateFile("test1.txt");
                temporaryFolder2.CreateFile("test3.txt");

                IFolderComparisonReport folderComparisonReport = temporaryFolder1.Compare(temporaryFolder2, ReportOption.CollectDifferentFiles);
                CollectionAssert.AreEqual(new[] {"test2.txt"}, folderComparisonReport.Folder1Files);
                CollectionAssert.AreEqual(new[] {"test3.txt"}, folderComparisonReport.Folder2Files);
                Assert.That(folderComparisonReport.Equal, Is.False);
            }
        }
 public void FolderComparison_NullAndNotExistsFolders_True()
 {
     using (var temporaryFolder = new TemporaryFolder())
     {
         IFolder folder1 = new DataFolder(temporaryFolder.Folder + "\\" + "test");
         IFolder folder2 = null;
         IFolderComparisonReport report = folder1.Compare(folder2);
         Assert.That(report.Equal, Is.True);
     }
 }
        public void FolderComparison_FoldersWithSameSubFolders_True()
        {
            using (var temporaryFolder1 = new TemporaryFolder())
            using (var temporaryFolder2 = new TemporaryFolder())
            {
                temporaryFolder1.CreateFolder("test1");
                temporaryFolder2.CreateFolder("test1");

                IFolderComparisonReport report = temporaryFolder1.Compare(temporaryFolder2);
                Assert.That(report.Equal, Is.True);
            }
        }
        public void FolderComparison_FoldersWithSameSubFoldersButDifferentFiles_False()
        {
            using (var temporaryFolder1 = new TemporaryFolder())
            using (var temporaryFolder2 = new TemporaryFolder())
            {
                IFolder folder1 = temporaryFolder1.CreateFolder("test");
                IFolder folder2 = temporaryFolder2.CreateFolder("test");

                folder1.CreateFile("file_1");
                folder2.CreateFile("file_2");
                IFolderComparisonReport report = temporaryFolder1.Compare(temporaryFolder2);
                Assert.That(report.Equal, Is.False);
            }
        }
        public void FolderComparison_FoldersWithDifferentSubFolders_False()
        {
            using (var temporaryFolder1 = new TemporaryFolder())
            using (var temporaryFolder2 = new TemporaryFolder())
            {
                temporaryFolder1.CreateFolder("test1");
                temporaryFolder2.CreateFolder("test2");

                IFolderComparisonReport report = temporaryFolder1.Compare(temporaryFolder2);
                Assert.That(report.Equal, Is.False);
            }
        }
 public void FolderComparison_FoldersWith1DifferentFile_False()
 {
     using (var temporaryFolder1 = new TemporaryFolder())
     using (var temporaryFolder2 = new TemporaryFolder())
     {
         temporaryFolder1.CreateFile("file_1");
         temporaryFolder2.CreateFile("file_2");
         IFolderComparisonReport report = temporaryFolder1.Compare(temporaryFolder2);
         Assert.That(report.Equal, Is.False);
     }
 }
        public void FolderComparison_FilesListNotFoundInFolderAndSubFolder_False()
        {
            using (var temporaryFolder = new TemporaryFolder())
            {
                temporaryFolder.CreateFile("file1.txt");
                temporaryFolder.CreateFile("file2.txt");
                IFolder subFolder = temporaryFolder.CreateFolder("subFolder");
                subFolder.CreateFile("subFolderFile1.dat");

                string[] filesList = new StringBuilder()
                    .AppendLine("file1.txt")
                    .AppendLine("file2.txt")
                    .AppendLine(@"subFolder\subFolderFile1.dat")
                    .AppendLine(@"subFolder\subFolderFile2.dat")
                    .ToString()
                    .Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);

                IFolderComparisonReport folderComparisonReport = temporaryFolder.Compare(filesList);
                Assert.That(folderComparisonReport.Equal, Is.False);
            }
        }
 public void FolderComparison_ExistsAndNullFolders_False()
 {
     using (var temporaryFolder = new TemporaryFolder())
     {
         IFolder nullFolder = null;
         IFolderComparisonReport report = temporaryFolder.Compare(nullFolder);
         Assert.That(report.Equal, Is.False);
     }
 }
 public void TemporaryFolder_basedOnITemporaryFolder()
 {
     var temporaryFolder = new TemporaryFolder();
     Assert.That(temporaryFolder, Is.InstanceOf<ITemporaryFolder>());
 }
 public void FolderComparison_EmptyAndEmptyFolders_True()
 {
     using (var temporaryFolder1 = new TemporaryFolder())
     using (var temporaryFolder2 = new TemporaryFolder())
     {
         IFolderComparisonReport report = temporaryFolder1.Compare(temporaryFolder2);
         Assert.That(report.Equal, Is.True);
     }
 }
 public void FolderComparison_Folder1With1FileAndFolder2With2Files_False()
 {
     using (var temporaryFolder1 = new TemporaryFolder())
     using (var temporaryFolder2 = new TemporaryFolder())
     {
         temporaryFolder1.CreateFile("file1_1");
         temporaryFolder2.CreateFile("file2_1");
         temporaryFolder2.CreateFile("file2_2");
         IFolderComparisonReport report = temporaryFolder1.Compare(temporaryFolder2);
         Assert.That(report.Equal, Is.False);
     }
 }
        public void FolderComparison_ExistsAndNotExistsFolders_False()
        {
            using (var temporaryFolder = new TemporaryFolder())
            {
                IFolder folder2 = new DataFolder(temporaryFolder.Folder + "\\" + "test2");

                IFolderComparisonReport report = temporaryFolder.Compare(folder2);
                Assert.That(report.Equal, Is.False);
            }
        }
示例#17
0
        public static IFolderComparisonReport Compare(this IFolder folder1, string[] folderContent2, ReportOption reportOption = ReportOption.EqualOnly)
        {
            if (folderContent2 == null)
            {
                IFolder folder2 = null;
                return folder1.Compare(folder2);
            }

            using (var temporaryFolder = new TemporaryFolder())
            {
                foreach (string folderEntity in folderContent2)
                {
                    temporaryFolder.CreateFile(folderEntity);
                }
                return folder1.Compare(temporaryFolder, reportOption);
            }
        }