|
23 | 23 | using FluentAssertions; |
24 | 24 | using MongoDB.Bson; |
25 | 25 | using MongoDB.Bson.Serialization.Serializers; |
26 | | -using MongoDB.TestHelpers.XunitExtensions; |
27 | 26 | using MongoDB.Driver.Core.Authentication; |
28 | 27 | using MongoDB.Driver.Core.Clusters; |
29 | 28 | using MongoDB.Driver.Core.Configuration; |
|
35 | 34 | using MongoDB.Driver.Core.WireProtocol.Messages; |
36 | 35 | using MongoDB.Driver.Core.WireProtocol.Messages.Encoders; |
37 | 36 | using MongoDB.Driver.Core.WireProtocol.Messages.Encoders.BinaryEncoders; |
| 37 | +using MongoDB.TestHelpers.XunitExtensions; |
38 | 38 | using Moq; |
39 | 39 | using Xunit; |
40 | 40 |
|
@@ -196,7 +196,7 @@ ResponseMessage CreateResponseMessage() |
196 | 196 | var section0 = new Type0CommandMessageSection<RawBsonDocument>( |
197 | 197 | new RawBsonDocument(BsonDocument.Parse(section0Document).ToBson()), |
198 | 198 | RawBsonDocumentSerializer.Instance); |
199 | | - return new CommandResponseMessage(new CommandMessage(1, RequestMessage.CurrentGlobalRequestId + 1, new[] { section0 }, false)); |
| 199 | + return new CommandResponseMessage(new CommandMessage(1, 1 /* will be overriden by IgnoreWritesMemoryStream */, new[] { section0 }, false)); |
200 | 200 | } |
201 | 201 | } |
202 | 202 |
|
@@ -877,9 +877,14 @@ public void SendMessages_should_put_the_messages_on_the_stream_and_raise_the_cor |
877 | 877 | private sealed class IgnoreWritesMemoryStream : MemoryStream |
878 | 878 | { |
879 | 879 | public IgnoreWritesMemoryStream(byte[] bytes) : base(bytes) { } |
| 880 | + |
880 | 881 | public override void Write(byte[] buffer, int offset, int count) |
881 | 882 | { |
882 | | - // Do nothing |
| 883 | + Position = 4; |
| 884 | + base.Write(buffer, 4, 4); // copy requestId |
| 885 | + base.Write(buffer, 4, 4); // set responseTo to requestId |
| 886 | + Position = 0; |
| 887 | + // do nothing else |
883 | 888 | } |
884 | 889 | } |
885 | 890 | } |
|
0 commit comments