Skip to content

Commit 19f41f1

Browse files
authored
CSHARP-4644: Flaky Open_should_create_authenticators_only_once (#1104)
1 parent 6b5b328 commit 19f41f1

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

tests/MongoDB.Driver.Core.Tests/Core/Connections/BinaryConnectionTests.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
using FluentAssertions;
2424
using MongoDB.Bson;
2525
using MongoDB.Bson.Serialization.Serializers;
26-
using MongoDB.TestHelpers.XunitExtensions;
2726
using MongoDB.Driver.Core.Authentication;
2827
using MongoDB.Driver.Core.Clusters;
2928
using MongoDB.Driver.Core.Configuration;
@@ -35,6 +34,7 @@
3534
using MongoDB.Driver.Core.WireProtocol.Messages;
3635
using MongoDB.Driver.Core.WireProtocol.Messages.Encoders;
3736
using MongoDB.Driver.Core.WireProtocol.Messages.Encoders.BinaryEncoders;
37+
using MongoDB.TestHelpers.XunitExtensions;
3838
using Moq;
3939
using Xunit;
4040

@@ -196,7 +196,7 @@ ResponseMessage CreateResponseMessage()
196196
var section0 = new Type0CommandMessageSection<RawBsonDocument>(
197197
new RawBsonDocument(BsonDocument.Parse(section0Document).ToBson()),
198198
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));
200200
}
201201
}
202202

@@ -877,9 +877,14 @@ public void SendMessages_should_put_the_messages_on_the_stream_and_raise_the_cor
877877
private sealed class IgnoreWritesMemoryStream : MemoryStream
878878
{
879879
public IgnoreWritesMemoryStream(byte[] bytes) : base(bytes) { }
880+
880881
public override void Write(byte[] buffer, int offset, int count)
881882
{
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
883888
}
884889
}
885890
}

0 commit comments

Comments
 (0)