public void TestCopy(){ GridFile fs = new GridFile(DB, "gfcopy"); GridFileStream gfs = fs.Create("original.txt"); gfs.WriteByte(1); gfs.Seek(1024 * 256 * 2, SeekOrigin.Begin); gfs.WriteByte(2); gfs.Close(); fs.Copy("original.txt", "copy.txt"); Assert.IsTrue(fs.Exists("original.txt")); Assert.IsTrue(fs.Exists("copy.txt")); //TODO Assert chunk data is the same too. }
public GridFileInfo(Database db, string filename) { this.db = db; this.bucket = "fs"; this.gridFile = new GridFile(db); SetFileDataDefaults(filename); if(gridFile.Exists(filename)) this.LoadFileData(); }
/// <summary> /// Initializes a new instance of the <see cref="GridFileInfo"/> class. /// </summary> /// <param name="db">The db.</param> /// <param name="bucket">The bucket.</param> /// <param name="filename">The filename.</param> public GridFileInfo(IMongoDatabase db, string bucket, string filename) { this.db = db; this.bucket = bucket; this.gridFile = new GridFile(db,bucket); SetFileDataDefaults(filename); if(gridFile.Exists(filename)) this.LoadFileData(); }
public void TestDelete() { String filename = "gfi-delete.txt"; GridFile gf = new GridFile(db["tests"],"gfdelete"); GridFileInfo gfi = new GridFileInfo(db["tests"],"gfdelete", filename); GridFileStream gfs = gfi.Create(); //TODO Expand Test to make sure that chunks for the file got deleted too. gfi.Delete(); Assert.IsFalse(gf.Exists(filename), "File should have been deleted."); }
public void TestDelete(){ String filename = "gfi-delete.txt"; GridFile gf = new GridFile(DB,"gfdelete"); GridFileInfo gfi = new GridFileInfo(DB,"gfdelete", filename); var id = gfi.Id; GridFileStream gfs = gfi.Create(); //TODO Expand Test to make sure that chunks for the file got deleted too. gfi.Delete(); Assert.IsFalse(gf.Exists(filename), "File should have been deleted."); Assert.IsTrue(0 == gf.Chunks.Count(new Document("_id", id))); }
public void TestCreateNonExisting(){ String filename = "newfile.txt"; GridFile gf = new GridFile(DB,"gfcreate"); GridFileInfo gfi = new GridFileInfo(DB,"gfcreate", filename); Assert.AreEqual(filename, gfi.FileName); GridFileStream gfs = gfi.Create(); Assert.AreEqual(filename, gfi.FileName, "Filename got erased?"); Assert.IsTrue(gf.Exists(gfi.FileName)); }
public void TestMoveTo(){ String filename = "gfi-move.txt"; String filename2 = "gfi-move.txt2"; GridFile gf = new GridFile(DB,"gfmove"); GridFileInfo gfi = new GridFileInfo(DB,"gfmove", filename); gfi.Create(); gfi.MoveTo(filename2); Assert.IsFalse(gf.Exists(filename), "File should have been moved."); Assert.IsTrue(gf.Exists(filename2), "File wasn't"); Assert.AreEqual(filename2, gfi.FileName, "Filename wasn't set in GridFileInfo"); }
public void TestFileDoesNotExist() { GridFile fs = new GridFile(DB); Assert.IsFalse(fs.Exists("non-existent filename")); }
public void TestFileDoes() { GridFile fs = new GridFile(DB); fs.Create("exists.txt"); Assert.IsTrue(fs.Exists("exists.txt")); }
public void TestMoveTo() { String filename = "gfi-move.txt"; String filename2 = "gfi-move.txt2"; GridFile gf = new GridFile(db["tests"],"gfmove"); GridFileInfo gfi = new GridFileInfo(db["tests"],"gfmove", filename); gfi.Create(); gfi.MoveTo(filename2); Assert.IsFalse(gf.Exists(filename), "File should have been moved."); Assert.IsTrue(gf.Exists(filename2), "File wasn't"); }