protected override void InitInternal() { base.InitInternal(); testFolder = Context.EmptyFolder; folderA = testFolder.AddFolder("a"); folderB = testFolder.AddFolder("b"); folderC = testFolder.AddFolder("c"); testFolder.AddFile(Context.DownloadFile0Template.FullName, "file0.doc", false); testFolder.AddFile(Context.DownloadFile0Template.FullName, "file0.txt", false); testFolder.AddFile(Context.DownloadFile1Template.FullName, "file1.doc", false); testFolder.AddFile(Context.DownloadFile1Template.FullName, "file1.txt", false); }
protected override void InitInternal() { base.InitInternal(); //create source and add two files source = Context.EmptyFolder.AddFolder("Source"); //sub folders source.AddFolder("folder0"); source.AddFolder("folder1"); //sub files source.AddFile(Context.DownloadFile0Template.FullName, "file0.bin", false); source.AddFile(Context.DownloadFile1Template.FullName, "file1.txt", false); targetPath = FileSystem.CreateFolderPath(Context.EmptyFolder.MetaData.FullName, "Target"); }
protected override void InitInternal() { base.InitInternal(); testFolder = Context.EmptyFolder; testFolder.AddFolder("dir_foo"); testFolder.AddFolder("dir_bar"); testFolder.AddFolder("dir_foobar"); testFolder.AddFolder("dir_barfoo"); testFolder.AddFile(Context.DownloadFile0Template.FullName, "foo.txt", false); testFolder.AddFile(Context.DownloadFile0Template.FullName, "bar.txt", false); testFolder.AddFile(Context.DownloadFile1Template.FullName, "foobar.txt", false); testFolder.AddFile(Context.DownloadFile1Template.FullName, "barfoo.txt", false); }
public void Creating_A_Folder_And_Adding_A_File_Should_Create_Items_On_File_System() { var foo = root.AddFolder("foo"); var bar = foo.AddFolder("bar"); FileInfo sourceFile = rootDirectory.GetFiles().First(); using(Stream stream = sourceFile.OpenRead()) { var foobar = bar.AddFile("foobar.bin", stream, false, sourceFile.Length, ContentUtil.UnknownContentType); Assert.AreEqual("foobar.bin", foobar.MetaData.Name); } var fooDir = rootDirectory.GetDirectories("foo").Single(); var barDir = fooDir.GetDirectories("bar").Single(); Assert.AreEqual(1, barDir.GetFiles().Count()); //create a file on root level sourceFile = rootDirectory.GetFiles().First(); using (Stream stream = sourceFile.OpenRead()) { var rootFile = root.AddFile("rootFile.bin", stream, false, sourceFile.Length, ContentUtil.UnknownContentType); Assert.AreEqual("rootFile.bin", rootFile.MetaData.Name); Assert.True(File.Exists(Path.Combine(rootDirectory.FullName, rootFile.MetaData.Name))); } }
public void Folders_Should_Indicate_Whether_They_Are_Empty_Or_Not() { //the test folder is not empty, but contains not sub folders and files testFolder.RefreshMetaData(); Assert.IsFalse(testFolder.MetaData.IsEmpty); //add sub folder to folder a folderA.AddFolder("x"); folderA.RefreshMetaData(); Assert.IsFalse(folderA.MetaData.IsEmpty); //add sub files to folder b folderA.AddFile(Context.DownloadFile0Template.FullName, "xxx.bin", false); folderA.RefreshMetaData(); Assert.IsFalse(folderA.MetaData.IsEmpty); //folder c is still empty folderC.RefreshMetaData(); Assert.IsTrue(folderC.MetaData.IsEmpty); }