Skip to content

Commit 31c93dd

Browse files
committed
CSHARP-915: added MaxWriteBatchSize to IsMasterResult
1 parent 756f9fa commit 31c93dd

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

MongoDB.Driver/CommandResults/IsMasterResult.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,17 @@ public int MinWireVersion
161161
get { return Response.GetValue("minWireVersion", 0).ToInt32(); }
162162
}
163163

164+
/// <summary>
165+
/// Gets the maximum size of the write batch.
166+
/// </summary>
167+
/// <value>
168+
/// The maximum size of the write batch.
169+
/// </value>
170+
public int MaxWriteBatchSize
171+
{
172+
get { return Response.GetValue("maxWriteBatchSize", 1000).ToInt32(); }
173+
}
174+
164175
/// <summary>
165176
/// Gets the message.
166177
/// </summary>

MongoDB.DriverUnitTests/CommandResults/IsMasterResultTests.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,30 @@ public void TestMaxMessageLengthWhenNotServerSuppliedUsesMaxBsonObjectSizeWhenLa
6262

6363
Assert.AreEqual(MongoDefaults.MaxMessageLength + 1024, result.MaxMessageLength);
6464
}
65+
66+
[Test]
67+
public void TestMaxWriteBatchSizeWhenServerSupplied()
68+
{
69+
var document = new BsonDocument
70+
{
71+
{ "ok", 1 },
72+
{ "maxWriteBatchSize", 200 }
73+
};
74+
var result = new IsMasterResult(document);
75+
76+
Assert.AreEqual(200, result.MaxWriteBatchSize);
77+
}
78+
79+
[Test]
80+
public void TestMaxWriteBatchSizeWhenNotServerSupplied()
81+
{
82+
var document = new BsonDocument
83+
{
84+
{ "ok", 1 }
85+
};
86+
var result = new IsMasterResult(document);
87+
88+
Assert.AreEqual(1000, result.MaxWriteBatchSize);
89+
}
6590
}
6691
}

0 commit comments

Comments
 (0)