forked from samus/mongodb-csharp
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of git://github.com/samus/mongodb-csharp
Conflicts: MongoDB.Net-Tests/Bson/TestBsonDocument.cs MongoDB.Net-Tests/MongoDB.Driver.Tests.csproj MongoDB.Net-Tests/PartCover/Coverage.Xml MongoDB.Net-Tests/TestCollection.cs MongoDB.Net-Tests/TestCursor.cs MongoDBDriver/Bson/BsonConvert.cs MongoDBDriver/Bson/BsonDocument.cs MongoDBDriver/Bson/BsonLong.cs MongoDBDriver/Bson/Types.cs MongoDBDriver/Collection.cs MongoDBDriver/Cursor.cs MongoDBDriver/MongoDB.Driver.csproj
- Loading branch information
Showing
14 changed files
with
10,560 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
*.dll | ||
*.pdb | ||
*.xml | ||
obj/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* User: scorder | ||
*/ | ||
|
||
using System; | ||
using System.IO; | ||
|
||
using NUnit.Framework; | ||
|
||
namespace MongoDB.Driver.Bson | ||
{ | ||
[TestFixture] | ||
public class TestBsonArray | ||
{ | ||
[Test] | ||
public void TestType(){ | ||
Assert.AreEqual(BsonDataType.Array, (BsonDataType)new BsonArray().TypeNum); | ||
} | ||
|
||
[Test] | ||
public void TestOnlyNumericKeys(){ | ||
bool thrown = false; | ||
BsonArray ba = new BsonArray(); | ||
ba.Add("1","A"); | ||
Assert.IsNotNull(ba["1"]); | ||
try { | ||
ba.Add("A","A"); | ||
} catch (ArgumentOutOfRangeException) { | ||
thrown = true; | ||
} | ||
if(thrown != true) Assert.Fail("Exception should have been thrown"); | ||
|
||
thrown = false; | ||
try { | ||
ba["A"] = new BsonElement("A", new BsonString("A")); | ||
} catch (ArgumentOutOfRangeException) { | ||
thrown = true; | ||
} | ||
if(thrown != true) Assert.Fail("Exception should have been thrown"); | ||
} | ||
|
||
[Test] | ||
public void TestKeysCanBeInts(){ | ||
BsonArray ba = new BsonArray(); | ||
ba.Add(1,"A"); | ||
Assert.AreEqual("A", ba[1].Val.ToNative()); | ||
} | ||
|
||
[Test] | ||
public void TestKeyHoles(){ | ||
BsonArray ba = new BsonArray(); | ||
ba.Add(1,"A"); | ||
ba.Add(3,"C"); | ||
Assert.IsNull(ba[2]); | ||
} | ||
|
||
[Test] | ||
public void TestKeyOrdering(){ | ||
BsonArray ba = new BsonArray(); | ||
ba.Add(1,"A"); | ||
ba.Add(2,"B"); | ||
ba.Add(5,"E"); | ||
ba.Add(3,"C"); | ||
ba.Add(4,"D"); | ||
|
||
int ikey = 1; | ||
foreach(string key in ba.Keys){ | ||
Assert.AreEqual(ikey, int.Parse(key)); | ||
ikey++; | ||
} | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46213,5 +46213,4 @@ | |
<pt visit="1" pos="0" len="9" /> | ||
</code> | ||
</method> | ||
</type> | ||
</PartCoverReport> | ||
</type> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.