public Create ( String filename ) : |
||
filename | String | |
return |
public void TestFileDoes() { GridFile fs = new GridFile(db["tests"]); fs.Create("exists.txt"); Assert.IsTrue(fs.Exists("exists.txt")); }
public void TestWrite() { GridFileStream gfs = fs.Create("test.txt"); Object id = gfs.GridFileInfo.Id; for (byte b = (byte)0; b < 128; b++) { gfs.WriteByte(b); } gfs.Close(); Assert.AreEqual(1, CountChunks(filesystem, id)); Document chunk = GrabChunk(id, 0); Binary bin = (Binary)chunk["data"]; Assert.AreEqual(127, bin.Bytes[127]); Assert.AreEqual(0, bin.Bytes[0]); }
public void TestModeCreateNew(){ Object id; string filename = "createnew.txt"; GridFile gf = new GridFile(DB,"gfcreate"); using(GridFileStream gfs = gf.Create(filename, FileMode.CreateNew)){ id = gfs.GridFileInfo.Id; TextWriter tw = new StreamWriter(gfs); tw.WriteLine("test"); tw.Close(); } Assert.AreEqual(1, CountChunks("gfcreate", id)); }
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 void TestModeCreateNew() { Object id; string filename = "createnew.txt"; GridFile gf = new GridFile(db["tests"], "gfcreate"); using (GridFileStream gfs = gf.Create(filename, FileMode.CreateNew)){ id = gfs.GridFileInfo.Id; TextWriter tw = new StreamWriter(gfs); tw.WriteLine("test"); tw.Close(); } Assert.AreEqual(1, CountChunks("gfcreate", id)); }
public void TestCopy() { GridFile fs = new GridFile(db["tests"], "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 void TestDeleteRemovesChunks(){ Object id; string filename = "deletebyname.txt"; string fs = "fs"; GridFile gf = new GridFile(DB,fs); using(GridFileStream gfs = gf.Create(filename, FileMode.CreateNew)){ id = gfs.GridFileInfo.Id; TextWriter tw = new StreamWriter(gfs); tw.WriteLine("test"); tw.Close(); } Assert.AreEqual(1, CountChunks(fs, id), "Chunks not found"); gf.Delete("deletebyname.txt"); Assert.AreEqual(0, CountChunks(fs, id), "Chunks found"); }
public void TestDeleteRemovesChunks() { Object id; string filename = "deletebyname.txt"; string fs = "fs"; GridFile gf = new GridFile(DB, fs); using (GridFileStream gfs = gf.Create(filename, FileMode.CreateNew)){ id = gfs.GridFileInfo.Id; TextWriter tw = new StreamWriter(gfs); tw.WriteLine("test"); tw.Close(); } Assert.AreEqual(1, CountChunks(fs, id), "Chunks not found"); gf.Delete("deletebyname.txt"); Assert.AreEqual(0, CountChunks(fs, id), "Chunks found"); }
public void TestOpenReadOnly() { string filename = "gfi-open.txt"; GridFile gf = new GridFile(DB, "gfopen"); GridFileStream gfs = gf.Create(filename); gfs.Close(); gfs = gf.OpenRead(filename); Assert.IsNotNull(gfs); bool thrown = false; try{ gfs.Write(new byte[] { 0 }, 0, 1); }catch (System.NotSupportedException) { thrown = true; }catch (Exception ex) { Assert.Fail("Wrong exception thrown " + ex.GetType().Name); } Assert.IsTrue(thrown, "NotSupportedException not thrown"); }
public void TestOpenReadOnly() { string filename = "gfi-open.txt"; GridFile gf = new GridFile(db["tests"], "gfopen"); GridFileStream gfs = gf.Create(filename); gfs.Close(); gfs = gf.OpenRead(filename); Assert.IsNotNull(gfs); bool thrown = false; try{ gfs.Write(new byte[]{0},0,1); }catch(System.NotSupportedException){ thrown = true; }catch(Exception ex){ Assert.Fail("Wrong exception thrown " + ex.GetType().Name); } Assert.IsTrue(thrown, "NotSupportedException not thrown"); }
public void TestFileDoes() { GridFile fs = new GridFile(DB); fs.Create("exists.txt"); Assert.IsTrue(fs.Exists("exists.txt")); }