Skip to content

Commit d8569f4

Browse files
committed
Corrected API
1 parent d8e1ecd commit d8569f4

File tree

2 files changed

+34
-9
lines changed

2 files changed

+34
-9
lines changed

src/MongoDB.Driver/Core/Configuration/TcpStreamSettings.cs

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,40 @@ public TimeSpan? WriteTimeout
196196
/// <param name="receiveBufferSize">Size of the receive buffer.</param>
197197
/// <param name="sendBufferSize">Size of the send buffer.</param>
198198
/// <param name="socketConfigurator">The socket configurator.</param>
199-
/// <param name="socks5ProxySettings">The SOCKS5 proxy settings.</param>
200199
/// <param name="writeTimeout">The write timeout.</param>
201200
/// <returns>A new TcpStreamSettings instance.</returns>
202201
public TcpStreamSettings With(
202+
Optional<AddressFamily> addressFamily = default(Optional<AddressFamily>),
203+
Optional<TimeSpan> connectTimeout = default(Optional<TimeSpan>),
204+
Optional<TimeSpan?> readTimeout = default(Optional<TimeSpan?>),
205+
Optional<int> receiveBufferSize = default(Optional<int>),
206+
Optional<int> sendBufferSize = default(Optional<int>),
207+
Optional<Action<Socket>> socketConfigurator = default(Optional<Action<Socket>>),
208+
Optional<TimeSpan?> writeTimeout = default(Optional<TimeSpan?>))
209+
{
210+
return new TcpStreamSettings(
211+
addressFamily: addressFamily.WithDefault(_addressFamily),
212+
connectTimeout: connectTimeout.WithDefault(_connectTimeout),
213+
readTimeout: readTimeout.WithDefault(_readTimeout),
214+
receiveBufferSize: receiveBufferSize.WithDefault(_receiveBufferSize),
215+
sendBufferSize: sendBufferSize.WithDefault(_sendBufferSize),
216+
socketConfigurator: socketConfigurator.WithDefault(_socketConfigurator),
217+
writeTimeout: writeTimeout.WithDefault(_writeTimeout));
218+
}
219+
220+
/// <summary>
221+
/// Returns a new TcpStreamSettings instance with some settings changed.
222+
/// </summary>
223+
/// <param name="addressFamily">The address family.</param>
224+
/// <param name="connectTimeout">The connect timeout.</param>
225+
/// <param name="readTimeout">The read timeout.</param>
226+
/// <param name="receiveBufferSize">Size of the receive buffer.</param>
227+
/// <param name="sendBufferSize">Size of the send buffer.</param>
228+
/// <param name="socketConfigurator">The socket configurator.</param>
229+
/// <param name="socks5ProxySettings">The SOCKS5 proxy settings.</param>
230+
/// <param name="writeTimeout">The write timeout.</param>
231+
/// <returns>A new TcpStreamSettings instance.</returns>
232+
public TcpStreamSettings WithSocks5Settings(
203233
Optional<AddressFamily> addressFamily = default(Optional<AddressFamily>),
204234
Optional<TimeSpan> connectTimeout = default(Optional<TimeSpan>),
205235
Optional<TimeSpan?> readTimeout = default(Optional<TimeSpan?>),

tests/MongoDB.Driver.Tests/Specifications/socks5-support/Socks5SupportProseTests.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
using MongoDB.Driver.Core.Events;
2222
using MongoDB.Driver.Core.Misc;
2323
using MongoDB.Driver.Core.TestHelpers.Logging;
24+
using MongoDB.Driver.Core.TestHelpers.XunitExtensions;
25+
using MongoDB.TestHelpers.XunitExtensions;
2426
using Xunit;
2527
using Xunit.Abstractions;
2628

@@ -62,13 +64,6 @@ public static IEnumerable<object[]> GetTestCombinations()
6264
}
6365
}
6466

65-
/* TODO:
66-
* - check if apiCompat is ok
67-
* - Drivers MUST verify for at least one of the connection strings marked (succeeds)
68-
* that command monitoring events do not reference the SOCKS5 proxy host where the MongoDB service server/port are referenced.
69-
*
70-
*/
71-
7267
[Theory]
7368
[MemberData(nameof(GetTestCombinations))]
7469
public async Task TestConnectionStrings(string id, string connectionString, bool expectedResult, bool useTls, bool async)
@@ -103,8 +98,8 @@ public async Task TestConnectionStrings(string id, string connectionString, bool
10398
};
10499

105100
var client = new MongoClient(mongoClientSettings);
106-
107101
var database = client.GetDatabase("admin");
102+
108103
var command = new BsonDocument("hello", 1);
109104

110105
if (expectedResult)

0 commit comments

Comments
 (0)