Browse Source

- fix large message

- make the default message size compat with 1.6 branch
pull/17/head
Testo 15 years ago
parent
commit
3f45e055d5
  1. 2
      Driver/Internal/MongoRequestMessage.cs
  2. 2
      Driver/MongoDefaults.cs
  3. 28
      DriverOnlineTests/Core/MongoCollectionTests.cs
  4. 2
      DriverOnlineTests/DriverOnlineTests.csproj

2
Driver/Internal/MongoRequestMessage.cs

@ -86,7 +86,7 @@ namespace MongoDB.Driver.Internal {
#region protected methods
protected void BackpatchMessageLength() {
int messageLength = buffer.Position - messageStartPosition;
messageLength = buffer.Position - messageStartPosition;
buffer.Backpatch(messageStartPosition, messageLength);
}

2
Driver/MongoDefaults.cs

@ -23,7 +23,7 @@ namespace MongoDB.Driver {
public static class MongoDefaults {
#region public static fields
private static TimeSpan connectTimeout = TimeSpan.FromSeconds(30);
private static int maxMessageLength = 16 * 1024 * 1204; // 16MB
private static int maxMessageLength = 4 * 1024 * 1204; // 4MB
private static int tcpReceiveBufferSize = 4 * 1024 * 1204; // 4MB
private static int tcpSendBufferSize = 4 * 1024 * 1204; // 4MB
#endregion

28
DriverOnlineTests/Core/MongoCollectionTests.cs

@ -17,6 +17,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MongoDB.Driver.Builders;
using NUnit.Framework;
using MongoDB.Bson;
@ -63,5 +64,32 @@ namespace MongoDB.DriverOnlineTests {
Assert.AreEqual("_id", result.GetElement(0).Name);
Assert.AreEqual("x", result.GetElement(1).Name);
}
[Test]
public void TestSortAndLimit()
{
collection.RemoveAll();
collection.Insert(new BsonDocument { { "x", 4 }, { "y", 2 } });
collection.Insert(new BsonDocument { { "x", 2 }, { "y", 2 } });
collection.Insert(new BsonDocument { { "x", 3 }, { "y", 2 } });
collection.Insert(new BsonDocument { { "x", 1 }, { "y", 2 } });
var result = collection.FindAll().SetSortOrder("x").SetLimit(3).Select(x=>x["x"].AsInt32);
Assert.AreEqual(3, result.Count());
CollectionAssert.AreEqual(new[] {1, 2, 3}, result);
}
[Test]
public void TestFind()
{
collection.RemoveAll();
collection.Insert(new BsonDocument { { "x", 4 }, { "y", 2 } });
collection.Insert(new BsonDocument { { "x", 2 }, { "y", 2 } });
collection.Insert(new BsonDocument { { "x", 3 }, { "y", 2 } });
collection.Insert(new BsonDocument { { "x", 1 }, { "y", 2 } });
var result = collection.Find(Query.GT("x", BsonValue.Create(3)));
Assert.AreEqual(1, result.Count());
Assert.AreEqual(4, result.Select(x=>x["x"].AsInt32).FirstOrDefault());
}
}
}

2
DriverOnlineTests/DriverOnlineTests.csproj

@ -74,6 +74,7 @@
<Compile Include="Core\MongoDatabaseTests.cs" />
<Compile Include="Core\MongoServerTests.cs" />
<Compile Include="Jira\CSharp77Tests.cs" />
<Compile Include="Performance\Class1.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
@ -103,6 +104,7 @@
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

Loading…
Cancel
Save