Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added a test to test the CreateNew mode.

Updated the Readme to reflect some of the current state.
  • Loading branch information...
commit 4189880ca8410c6049755a5e0e9ad460e312c4da 1 parent e3631c6
@samus authored
View
18 MongoDB.GridFS.Tests/GridFileInfoTest.cs
@@ -40,6 +40,20 @@ public class GridFileInfoTest
}
[Test]
+ public void TestModeCreateNew(){
+ Object id;
+ string filename = "createnew.txt";
+ GridFileInfo gfi = new GridFileInfo(db["tests"],"gfcreate", filename);
+ using(GridFileStream gfs = gfi.Create(FileMode.CreateNew)){
+ id = gfs.GridFileInfo.Id;
+ TextWriter tw = new StreamWriter(gfs);
+ tw.WriteLine("test");
+ tw.Close();
+ }
+ Assert.AreEqual(1, CountChunks("gfcreate", id));
+ }
+
+ [Test]
public void TestDelete(){
String filename = "gfi-delete.txt";
GridFile gf = new GridFile(db["tests"],"gfdelete");
@@ -122,5 +136,9 @@ public class GridFileInfoTest
}catch(MongoCommandException){}//if it fails it is because the collection isn't there to start with.
}
+
+ protected long CountChunks(string filesystem, Object fileid){
+ return db["tests"][filesystem + ".chunks"].Count(new Document().Append("files_id", fileid));
+ }
}
}
View
20 MongoDB.GridFS.Tests/GridFileTest.cs
@@ -37,6 +37,20 @@ public class GridFileTest{
//TODO Assert chunk data is the same too.
}
+ [Test]
+ 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));
+ }
+
[TestFixtureSetUp]
public void Init(){
db.Connect();
@@ -51,6 +65,7 @@ public class GridFileTest{
protected void CleanDB(){
//Any collections that we might want to delete before the tests run should be done here.
DropGridFileSystem("gfcopy");
+ DropGridFileSystem("gfcreate");
DropGridFileSystem("fs");
}
@@ -61,5 +76,10 @@ public class GridFileTest{
}catch(MongoCommandException){}//if it fails it is because the collection isn't there to start with.
}
+
+ protected long CountChunks(string filesystem, Object fileid){
+ return db["tests"][filesystem + ".chunks"].Count(new Document().Append("files_id", fileid));
+ }
+
}
}
View
6 README.rst
@@ -20,6 +20,7 @@ Current Features
- Authentication (Does not reauthorize on auto reconnect yet).
- Database Commands
- Basic Linq support
+- GridFS support
Missing Features
================
@@ -28,7 +29,6 @@ Missing Features
- Exceptions (In progress)
- hint, explain, $where
- database profiling: set/get profiling level, get profiling info
-- GridFS support (In progress)
- Many unit tests
Installation
@@ -52,6 +52,10 @@ At the simplest query the database like this:
Document result = db["tests"]["reads"].FindOne(query);
db.Disconnect();
+Getting Help
+===========
+The Google Group mongodb-csharp at (http://http://groups.google.com/group/mongodb-csharp) is the best place to go.
+
Contributors
============
- Sam Corder (samus)
Please sign in to comment.
Something went wrong with that request. Please try again.