public FolderTests() { _folder.Create(); _folder.CombineFile("Test_0_1.txt").Write("0_1"); _folder.CombineFile("Test_0_2.txt").Write("0_2"); var subfolder1 = _folder.CombineFolder("SubFolder_1"); subfolder1.Create(); subfolder1.CombineFile("Test_1_1.txt").Write("1_1"); subfolder1.CombineFile("Test_1_2.txt").Write("1_2"); var subfolder11 = subfolder1.CombineFolder("SubFolder_1_1"); subfolder11.Create(); subfolder11.CombineFile("Test_1_1_1.txt").Write("1_1_1"); subfolder11.CombineFile("Test_1_1_2.txt").Write("1_1_2"); var subfolder12 = subfolder1.CombineFolder("SubFolder_1_2"); subfolder12.Create(); subfolder12.CombineFile("Test_1_2_1.txt").Write("1_2_1"); subfolder12.CombineFile("Test_1_2_2.txt").Write("1_2_2"); var subfolder2 = _folder.CombineFolder("SubFolder_2"); subfolder2.Create(); subfolder2.CombineFile("Test_2_1.txt").Write("2_1"); subfolder2.CombineFile("Test_2_2.txt").Write("2_2"); var subfolder21 = subfolder2.CombineFolder("SubFolder_2_1"); subfolder21.Create(); subfolder21.CombineFile("Test_2_1_1.txt").Write("2_1_1"); subfolder21.CombineFile("Test_2_1_2.txt").Write("2_1_2"); var subfolder22 = subfolder2.CombineFolder("SubFolder_2_2"); subfolder22.Create(); subfolder22.CombineFile("Test_2_2_1.txt").Write("2_2_1"); subfolder22.CombineFile("Test_2_2_2.txt").Write("2_2_2"); }
public override void Copy(FsFolder destination) { destination.Create(); foreach (var subFolder in SearchFolders()) { var subpath = subFolder.Path.Substring(Path.Length); destination.CombineFolder(subpath).Create(); } foreach (var file in SearchFiles()) { var subFile = file.Path.Substring(Path.Length); file.Copy(destination.CombineFile(subFile)); } }
public override void SyncStructure(FsFolder destination, bool force) { var folders = Folders.ToList(); var destFolders = destination.Folders.ToList(); foreach (var subFolder in destFolders.Except(folders)) { destination.CombineFolder(subFolder.SubPath).Remove(); } foreach (var subFile in destination.Files.Except(Files)) { destination.CombineFile(subFile.SubPath).Remove(); } foreach (var folder in folders.Except(destFolders)) { destination.CombineFolder(folder.SubPath).Create(); } }
public void ShouldCopySmallFile() { var progresses = new List <(long, long)>(); var source = _folder.CombineFile("test1.txt"); File.WriteAllText(source, "ABCD"); var sut = new FileEx((x, y) => progresses.Add((x, y))); sut.Copy(_folder.CombineFile("test1.txt"), _folder.CombineFile("test2.txt")); Assert.That(progresses.SingleOrDefault().Item1, Is.EqualTo(progresses.SingleOrDefault().Item2)); Assert.That(progresses.SingleOrDefault().Item1, Is.EqualTo(source.Size)); Assert.That(File.Exists(_folder.CombineFile("test2.txt").ToString())); Assert.That( _folder.CombineFile("test1.txt").Content, Is.EqualTo(_folder.CombineFile("test2.txt").Content)); }
public void ShouldReturnEncoding() { var sut = _folder.CombineFile(nameof(ShouldReturnEncoding)); sut.Write("A"); Assert.That(sut.Encoding, Is.EqualTo(Encoding.UTF8)); File.WriteAllText(sut, "AV", Encoding.ASCII); Assert.That(sut.Encoding, Is.EqualTo(Encoding.ASCII)); }