Skip to content
This repository has been archived by the owner on Dec 30, 2020. It is now read-only.

Commit

Permalink
Making the current branch more backward compatible.
Browse files Browse the repository at this point in the history
  • Loading branch information
samus committed Mar 21, 2010
1 parent 44a4cd1 commit 08516f9
Show file tree
Hide file tree
Showing 32 changed files with 1,761 additions and 474 deletions.
2 changes: 1 addition & 1 deletion MongoDB.Driver.Benchmark/Main.cs
Expand Up @@ -254,7 +254,7 @@ public static void Main (string[] args)

static void DoFind(MongoDatabase db, string col, Document spec){
for(int i = 0; i < perTrial; i++){
ICursor<Document> cur = db[col].Find(spec);
ICursor cur = db[col].Find(spec);
foreach(Document d in cur.Documents){
}
}
Expand Down
12 changes: 6 additions & 6 deletions MongoDB.GridFS/GridFile.cs
Expand Up @@ -13,14 +13,14 @@ public class GridFile{
get { return name; }
}

private IMongoCollection<Document> files;
public IMongoCollection<Document> Files
private IMongoCollection files;
public IMongoCollection Files
{
get { return this.files; }
}

private IMongoCollection<Document> chunks;
public IMongoCollection<Document> Chunks
private IMongoCollection chunks;
public IMongoCollection Chunks
{
get { return this.chunks; }
}
Expand All @@ -35,11 +35,11 @@ public IMongoCollection<Document> Chunks
this.name = bucket;
}

public ICursor<Document> ListFiles(){
public ICursor ListFiles(){
return this.ListFiles(new Document());
}

public ICursor<Document> ListFiles(Document query)
public ICursor ListFiles(Document query)
{
return this.files.Find(new Document().Add("query", query)
.Add("orderby", new Document()
Expand Down
10 changes: 5 additions & 5 deletions MongoDB.GridFS/GridFileStream.cs
Expand Up @@ -19,8 +19,8 @@ namespace MongoDB.GridFS
public class GridFileStream : Stream
{

private IMongoCollection<Document> files;
private IMongoCollection<Document> chunks;
private IMongoCollection files;
private IMongoCollection chunks;
private Document chunk;
private bool chunkDirty;
private long chunkLower = -1;
Expand Down Expand Up @@ -65,8 +65,8 @@ public class GridFileStream : Stream
}
#endregion

public GridFileStream (GridFileInfo gridfileinfo, IMongoCollection<Document> files,
IMongoCollection<Document> chunks, FileAccess access)
public GridFileStream (GridFileInfo gridfileinfo, IMongoCollection files,
IMongoCollection chunks, FileAccess access)
{
switch (access) {
case FileAccess.Read:
Expand Down Expand Up @@ -364,7 +364,7 @@ private void EnsureNoHoles ()

Binary data = new Binary (this.blankBuffer);
int i = 0;
using(ICursor<Document> cur = chunks.Find(new Document().Add("query", query).Add("sort", sort), 0, 0, fields)){
using(ICursor cur = chunks.Find(new Document().Add("query", query).Add("sort", sort), 0, 0, fields)){
foreach (Document doc in cur.Documents) {
int n = Convert.ToInt32 (doc["n"]);
if (i < n) {
Expand Down
10 changes: 5 additions & 5 deletions MongoDB.Linq.Tests/TestMongoDocumentQuerySyntax.cs
@@ -1,4 +1,4 @@
using System;
using System;
using System.Diagnostics;
using System.Linq;
using MongoDB.Driver;
Expand All @@ -11,14 +11,14 @@ namespace MongoDB.Linq.Tests {
public class TestMongoDocumentQuerySyntax {

private IMongoQuery queryable;
private Mock<IMongoCollection<Document>> collectionMock;
private Mock<ICursor<Document>> cursorMock;
private Mock<IMongoCollection> collectionMock;
private Mock<ICursor> cursorMock;

[SetUp]
public void Setup() {
Debug.WriteLine("initializing queryable");
collectionMock = new Mock<IMongoCollection<Document>>();
cursorMock = new Mock<ICursor<Document>>();
collectionMock = new Mock<IMongoCollection>();
cursorMock = new Mock<ICursor>();
collectionMock.Setup(c => c.Find(It.IsAny<Document>(), It.IsAny<int>(), It.IsAny<int>(), It.IsAny<Document>())).Returns(cursorMock.Object);
queryable = new MongoQuery(new MongoQueryProvider(collectionMock.Object));
}
Expand Down
8 changes: 4 additions & 4 deletions MongoDB.Linq.Tests/TestQueryParsing.cs
Expand Up @@ -11,14 +11,14 @@ namespace MongoDB.Linq.Tests {
public class TestQueryParsing {

private IMongoQuery queryable;
private Mock<IMongoCollection<Document>> collectionMock;
private Mock<ICursor<Document>> cursorMock;
private Mock<IMongoCollection> collectionMock;
private Mock<ICursor> cursorMock;

[SetUp]
public void Setup() {
Debug.WriteLine("initializing queryable");
collectionMock = new Mock<IMongoCollection<Document>>();
cursorMock = new Mock<ICursor<Document>>();
collectionMock = new Mock<IMongoCollection>();
cursorMock = new Mock<ICursor>();
collectionMock.Setup(c => c.Find(It.IsAny<Document>(), It.IsAny<int>(), It.IsAny<int>(), It.IsAny<Document>())).Returns(cursorMock.Object);
queryable = new MongoQuery(new MongoQueryProvider(collectionMock.Object));
}
Expand Down
4 changes: 2 additions & 2 deletions MongoDB.Linq/MongoLinqEx.cs
@@ -1,11 +1,11 @@
using System;
using System;
using MongoDB.Driver;

namespace MongoDB.Linq
{
public static class MongoLinqEx
{
public static IMongoQuery AsQueryable<T>(this T collection) where T : IMongoCollection<Document>
public static IMongoQuery AsQueryable<T>(this T collection) where T : IMongoCollection
{
return new MongoQuery(new MongoQueryProvider(collection));
}
Expand Down
6 changes: 3 additions & 3 deletions MongoDB.Linq/MongoQueryProvider.cs
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
Expand All @@ -13,9 +13,9 @@ private struct Result {
public bool IsFirstCall;
}

private readonly IMongoCollection<Document> collection;
private readonly IMongoCollection collection;

public MongoQueryProvider(IMongoCollection<Document> collection)
public MongoQueryProvider(IMongoCollection collection)
{
this.collection = collection;
}
Expand Down
48 changes: 24 additions & 24 deletions MongoDB.Net-Tests/TestCollection.cs
Expand Up @@ -18,14 +18,14 @@ public class TestCollection : MongoTestBase
}

public override void OnInit (){
IMongoCollection<Document> finds = DB["finds"];
IMongoCollection finds = DB["finds"];
for(int j = 1; j < 100; j++){
finds.Insert(new Document(){{"x", 4},{"h", "hi"},{"j", j}});
}
for(int j = 100; j < 105; j++){
finds.Insert(new Document(){{"x", 4},{"n", 1},{"j", j}});
}
IMongoCollection<Document> charreads = DB["charreads"];
IMongoCollection charreads = DB["charreads"];
charreads.Insert(new Document(){{"test", "1234" + pound + "56"}});

}
Expand Down Expand Up @@ -64,7 +64,7 @@ public class TestCollection : MongoTestBase
Document fields = new Document();
fields["x"] = 1;

ICursor<Document> c = DB["finds"].Find(query, -1, 0, fields);
ICursor c = DB["finds"].Find(query, -1, 0, fields);
foreach(Document result in c.Documents){
Assert.IsNotNull(result);
Assert.AreEqual(4, result["x"]);
Expand All @@ -77,7 +77,7 @@ public class TestCollection : MongoTestBase
Document query = new Document();
query["j"] = new Document().Add("$gt", 20);

ICursor<Document> c = DB["finds"].Find(query);
ICursor c = DB["finds"].Find(query);
foreach(Document result in c.Documents){
Assert.IsNotNull(result);
Object j = result["j"];
Expand All @@ -88,7 +88,7 @@ public class TestCollection : MongoTestBase
[Test]
public void TestManualWhere(){
Document query = new Document().Add("$where", new Code("this.j % 2 == 0"));
ICursor<Document> c = DB["finds"].Find(query);
ICursor c = DB["finds"].Find(query);
foreach(Document result in c.Documents){
Assert.IsNotNull(result);
Object j = result["j"];
Expand All @@ -97,7 +97,7 @@ public class TestCollection : MongoTestBase
}
[Test]
public void TestFindWhereEquivalency(){
IMongoCollection<Document> col = DB["finds"];
IMongoCollection col = DB["finds"];
Document lt = new Document().Add("j", new Document().Add("$lt", 5));
string where = "this.j < 5";
Document explicitWhere = new Document().Add("$where", new Code(where));
Expand All @@ -110,7 +110,7 @@ public class TestCollection : MongoTestBase
Assert.AreEqual(4, CountDocs(col.Find(funcDoc)), "Function where didn't return 4 docs");
}

private int CountDocs(ICursor<Document> cur)
private int CountDocs(ICursor cur)
{
int cnt = 0;
foreach(Document doc in cur.Documents){
Expand All @@ -120,7 +120,7 @@ private int CountDocs(ICursor<Document> cur)
}
[Test]
public void TestWhere(){
ICursor<Document> c = DB["finds"].Find("this.j % 2 == 0");
ICursor c = DB["finds"].Find("this.j % 2 == 0");
foreach(Document result in c.Documents){
Assert.IsNotNull(result);
Object j = result["j"];
Expand All @@ -139,7 +139,7 @@ private int CountDocs(ICursor<Document> cur)

[Test]
public void TestSimpleInsert(){
IMongoCollection<Document> inserts = DB["inserts"];
IMongoCollection inserts = DB["inserts"];
Document indoc = new Document();
indoc["song"] = "Palmdale";
indoc["artist"] = "Afroman";
Expand All @@ -154,7 +154,7 @@ private int CountDocs(ICursor<Document> cur)

[Test]
public void TestReallySimpleInsert(){
IMongoCollection<Document> inserts = DB["inserts"];
IMongoCollection inserts = DB["inserts"];
Document indoc = new Document();
indoc["y"] = 1;
indoc["x"] = 2;
Expand All @@ -167,7 +167,7 @@ private int CountDocs(ICursor<Document> cur)

[Test]
public void TestPoundSymbolInsert(){
IMongoCollection<Document> inserts = DB["inserts"];
IMongoCollection inserts = DB["inserts"];
Document indoc = new Document().Add("x", "1234" + pound + "56").Add("y", 1);
inserts.Insert(indoc);

Expand All @@ -178,7 +178,7 @@ private int CountDocs(ICursor<Document> cur)

[Test]
public void TestArrayInsert(){
IMongoCollection<Document> inserts = DB["inserts"];
IMongoCollection inserts = DB["inserts"];
Document indoc1 = new Document();
indoc1["song"] = "The Axe";
indoc1["artist"] = "Tinsley Ellis";
Expand All @@ -203,7 +203,7 @@ private int CountDocs(ICursor<Document> cur)
[Test]
public void TestInsertOfArray(){
OidGenerator ogen = new OidGenerator();
IMongoCollection<Document> inserts = DB["inserts"];
IMongoCollection inserts = DB["inserts"];
Document album = new Document();
album["_id"] = ogen.Generate();
album["artist"] = "Popa Chubby";
Expand All @@ -227,7 +227,7 @@ private int CountDocs(ICursor<Document> cur)
public void TestInsertLargerThan4MBDocument(){
Binary b = new Binary(new byte[1024 * 1024]);
Document big = new Document(){{"name", "Big Document"}, {"b1", b}, {"b2", b}, {"b3", b}, {"b4", b}};
IMongoCollection<Document> inserts = DB["inserts"];
IMongoCollection inserts = DB["inserts"];
bool thrown = false;
try{
inserts.Insert(big);
Expand All @@ -242,7 +242,7 @@ private int CountDocs(ICursor<Document> cur)
[Test]
public void TestInsertBulkLargerThan4MBOfDocuments(){
Binary b = new Binary(new byte[1024 * 1024 * 2]);
IMongoCollection<Document> inserts = DB["inserts"];
IMongoCollection inserts = DB["inserts"];
try{
Document[] docs = new Document[10];
//6MB+ of documents
Expand All @@ -259,7 +259,7 @@ private int CountDocs(ICursor<Document> cur)

[Test]
public void TestDelete(){
IMongoCollection<Document> deletes = DB["deletes"];
IMongoCollection deletes = DB["deletes"];
Document doc = new Document();
doc["y"] = 1;
doc["x"] = 2;
Expand All @@ -279,7 +279,7 @@ private int CountDocs(ICursor<Document> cur)

[Test]
public void TestUpdateUpsertNotExisting(){
IMongoCollection<Document> updates = DB["updates"];
IMongoCollection updates = DB["updates"];
Document doc = new Document();
doc["First"] = "Sam";
doc["Last"] = "CorderNE";
Expand All @@ -293,7 +293,7 @@ private int CountDocs(ICursor<Document> cur)

[Test]
public void TestUpdateUpsertExisting(){
IMongoCollection<Document> updates = DB["updates"];
IMongoCollection updates = DB["updates"];
Document doc = new Document();
doc["First"] = "Mtt";
doc["Last"] = "Brewer";
Expand All @@ -317,14 +317,14 @@ private int CountDocs(ICursor<Document> cur)

[Test]
public void TestUpdateMany(){
IMongoCollection<Document> updates = DB["updates"];
IMongoCollection updates = DB["updates"];

updates.Insert(new Document().Add("Last", "Cordr").Add("First", "Sam"));
updates.Insert(new Document().Add("Last", "Cordr").Add("First", "Sam2"));
updates.Insert(new Document().Add("Last", "Cordr").Add("First", "Sam3"));

Document selector = new Document().Add("Last", "Cordr");
ICursor<Document> results = updates.Find(selector);
ICursor results = updates.Find(selector);
bool found = false;
foreach(Document doc in results.Documents){
Assert.AreEqual("Cordr", doc["Last"]);
Expand Down Expand Up @@ -352,7 +352,7 @@ private int CountDocs(ICursor<Document> cur)

[Test]
public void TestUpdatePartial(){
IMongoCollection<Document> updates = DB["updates"];
IMongoCollection updates = DB["updates"];
int coolness = 5;
Document einstein = new Document(){{"Last", "Einstien"},{"First", "Albert"},{"Coolness",coolness++}};
updates.Insert(einstein);
Expand All @@ -368,7 +368,7 @@ private int CountDocs(ICursor<Document> cur)

[Test]
public void TestCount(){
IMongoCollection<Document> counts = DB["counts"];
IMongoCollection counts = DB["counts"];
int top = 100;
for(int i = 0; i < top; i++){
counts.Insert(new Document().Add("Last", "Cordr").Add("First", "Sam").Add("cnt", i));
Expand All @@ -379,7 +379,7 @@ private int CountDocs(ICursor<Document> cur)

[Test]
public void TestCountWithSpec(){
IMongoCollection<Document> counts = DB["counts_spec"];
IMongoCollection counts = DB["counts_spec"];
counts.Insert(new Document().Add("Last", "Cordr").Add("First", "Sam").Add("cnt", 1));
counts.Insert(new Document().Add("Last", "Cordr").Add("First", "Sam").Add("cnt", 2));
counts.Insert(new Document().Add("Last", "Corder").Add("First", "Sam").Add("cnt", 3));
Expand All @@ -392,7 +392,7 @@ private int CountDocs(ICursor<Document> cur)

[Test]
public void TestCountInvalidCollection(){
IMongoCollection<Document> counts = DB["counts_wtf"];
IMongoCollection counts = DB["counts_wtf"];
Assert.AreEqual(0, counts.Count());
}
}
Expand Down
2 changes: 1 addition & 1 deletion MongoDB.Net-Tests/TestCollectionMetaData.cs
Expand Up @@ -18,7 +18,7 @@ public class TestCollectionMetaData : MongoTestBase
}

public override void OnInit (){
IMongoCollection<Document> its = DB["indextests"];
IMongoCollection its = DB["indextests"];
its.Insert(createDoc("S","A","Anderson","OH"));
its.Insert(createDoc("T","B","Delhi","OH"));
its.Insert(createDoc("F","B","Cincinnati","OH"));
Expand Down

0 comments on commit 08516f9

Please sign in to comment.