Skip to content

Commit

Permalink
Merge remote branch 'samus/typedcollections' into typedcollections
Browse files Browse the repository at this point in the history
  • Loading branch information
lanwin committed Jun 9, 2010
2 parents f492b4a + b65eff1 commit 580be4f
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public void TestDisconnectedConnectionsArentReturndToPool()
}

[Test]
public void TestIfConnectionLifetimeIsReachedItDosenotReturndToPool()
public void TestIfConnectionLifetimeIsReachedItDoesNotReturndToPool()
{
var builder = new MongoConnectionStringBuilder
{
Expand Down
4 changes: 2 additions & 2 deletions source/MongoDB.Tests/IntegrationTests/TestMongo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void TestConnectThrowIfConnectionFailed(){
}

[Test]
public void TestTryConnectDoseNotThrowIfConnectionFailed(){
public void TestTryConnectDoesNotThrowIfConnectionFailed(){
using(var m = new Mongo("Server=notexists"))
Assert.IsFalse(m.TryConnect());
}
Expand All @@ -59,7 +59,7 @@ public void TestGetDatabasesReturnsSomething()
}
}

public void TestDoseNotThrowIfDisposeIsCalledTwice(){
public void TestDoesNotThrowIfDisposeIsCalledTwice(){
using(var m = new Mongo(_connectionString))
{
m.Dispose();
Expand Down
24 changes: 24 additions & 0 deletions source/MongoDB.Tests/UnitTests/Bson/BsonTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,29 @@ protected Document Deserialize(string base64, BsonReaderSettings settings)
return (Document)reader.ReadObject();
}
}


protected byte[] HexToBytes(string hex)
{
//TODO externalize somewhere.
if (hex.Length % 2 == 1)
{
Console.WriteLine("uneven number of hex pairs.");
hex = "0" + hex;
}
var numberChars = hex.Length;
var bytes = new byte[numberChars / 2];
for (var i = 0; i < numberChars; i += 2)
try
{
bytes[i / 2] = Convert.ToByte(hex.Substring(i, 2), 16);
}
catch
{
//failed to convert these 2 chars, they may contain illegal charracters
bytes[i / 2] = 0;
}
return bytes;
}
}
}
29 changes: 4 additions & 25 deletions source/MongoDB.Tests/UnitTests/Bson/TestBsonReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,29 +33,6 @@ private string WriteAndReadLenString(string val){
return reader.ReadLengthString();
}

private byte[] HexToBytes(string hex){
//TODO externalize somewhere.
if(hex.Length%2 == 1)
{
Console.WriteLine("uneven number of hex pairs.");
hex = "0" + hex;
}
var numberChars = hex.Length;
var bytes = new byte[numberChars/2];
for(var i = 0; i < numberChars; i += 2)
try
{
bytes[i/2] = Convert.ToByte(hex.Substring(i, 2), 16);
}
catch
{
//failed to convert these 2 chars, they may contain illegal charracters
bytes[i/2] = 0;
}
return bytes;
}


[Test]
public void TestReadDocWithDocs(){
// Document doc = new Document().Append("a", new Document().Append("b", new Document().Append("c",new Document())));
Expand Down Expand Up @@ -281,7 +258,7 @@ public void TestReadUtcTimeByDefault(){
var document = Deserialize("EwAAAAl0aW1lAADJU+klAQAAAA==");

var dateTime = new DateTime(2010, 1, 1, 10, 0, 0, DateTimeKind.Utc);

Assert.AreEqual(dateTime, document["time"]);
}

Expand All @@ -291,7 +268,9 @@ public void TestReadUtcTimeToLocalTime(){

var document = Deserialize("EwAAAAl0aW1lAADJU+klAQAAAA==", settings);

var dateTime = new DateTime(2010, 1, 1, 11, 0, 0, DateTimeKind.Local);
var localtzoffset =TimeZoneInfo.Local.BaseUtcOffset.Hours - 1; //gmt offset the local date was saved in along with the local offset.

var dateTime = new DateTime(2010, 1, 1, 11, 0, 0, DateTimeKind.Local).AddHours(localtzoffset);
Assert.AreEqual(dateTime, document["time"]);
}
}
Expand Down
8 changes: 6 additions & 2 deletions source/MongoDB.Tests/UnitTests/Bson/TestBsonWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,15 @@ public void TestCalculateSizeOfSimpleDoc()
[Test]
public void TestLocalDateTimeIsWrittenAsUtcTime()
{
var dateTime = new DateTime(2010, 1, 1, 10, 0, 0, DateTimeKind.Local);
var localtzoffset = TimeZoneInfo.Local.BaseUtcOffset.Hours;

var dateTime = new DateTime(2010, 1, 1, 11, 0, 0, DateTimeKind.Local);
var utcTime = new DateTime(2010, 1, 1, 11 - localtzoffset, 0, 0, DateTimeKind.Utc);

var base64 = Serialize(new Document("time", dateTime));
var expected = Serialize(new Document("time", utcTime));

Assert.AreEqual("EwAAAAl0aW1lAIDaHOklAQAAAA==", base64);
Assert.AreEqual(expected, base64);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace MongoDB.UnitTests.Serialization.Descriptors
{
[TestFixture]
[Ignore("Currently we dose not plan to support this. As alternative you can use Mo or Linq.")]
[Ignore("Currently we do not plan to support this. As an alternative you can use Mo or Linq.")]
public class ModifierTests : SerializationTestBase
{
public class ModifierEntity
Expand Down

0 comments on commit 580be4f

Please sign in to comment.