Skip to content

Commit

Permalink
CSHARP-4644: Flaky Open_should_create_authenticators_only_once (#1104)
Browse files Browse the repository at this point in the history
  • Loading branch information
BorisDog authored Jun 9, 2023
1 parent 6b5b328 commit 19f41f1
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
using FluentAssertions;
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Serializers;
using MongoDB.TestHelpers.XunitExtensions;
using MongoDB.Driver.Core.Authentication;
using MongoDB.Driver.Core.Clusters;
using MongoDB.Driver.Core.Configuration;
Expand All @@ -35,6 +34,7 @@
using MongoDB.Driver.Core.WireProtocol.Messages;
using MongoDB.Driver.Core.WireProtocol.Messages.Encoders;
using MongoDB.Driver.Core.WireProtocol.Messages.Encoders.BinaryEncoders;
using MongoDB.TestHelpers.XunitExtensions;
using Moq;
using Xunit;

Expand Down Expand Up @@ -196,7 +196,7 @@ ResponseMessage CreateResponseMessage()
var section0 = new Type0CommandMessageSection<RawBsonDocument>(
new RawBsonDocument(BsonDocument.Parse(section0Document).ToBson()),
RawBsonDocumentSerializer.Instance);
return new CommandResponseMessage(new CommandMessage(1, RequestMessage.CurrentGlobalRequestId + 1, new[] { section0 }, false));
return new CommandResponseMessage(new CommandMessage(1, 1 /* will be overriden by IgnoreWritesMemoryStream */, new[] { section0 }, false));
}
}

Expand Down Expand Up @@ -877,9 +877,14 @@ public void SendMessages_should_put_the_messages_on_the_stream_and_raise_the_cor
private sealed class IgnoreWritesMemoryStream : MemoryStream
{
public IgnoreWritesMemoryStream(byte[] bytes) : base(bytes) { }

public override void Write(byte[] buffer, int offset, int count)
{
// Do nothing
Position = 4;
base.Write(buffer, 4, 4); // copy requestId
base.Write(buffer, 4, 4); // set responseTo to requestId
Position = 0;
// do nothing else
}
}
}
Expand Down

0 comments on commit 19f41f1

Please sign in to comment.