-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Expand file tree
/
Copy pathCosmosDbContextOptionsBuilderExtensions.cs
More file actions
33 lines (27 loc) · 1.19 KB
/
CosmosDbContextOptionsBuilderExtensions.cs
File metadata and controls
33 lines (27 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using Microsoft.Azure.Cosmos;
namespace Microsoft.EntityFrameworkCore.TestUtilities;
public static class CosmosDbContextOptionsBuilderExtensions
{
private static HttpMessageHandler? _handler;
private static Func<HttpClient>? _httpClientFactory;
public static CosmosDbContextOptionsBuilder ApplyConfiguration(this CosmosDbContextOptionsBuilder optionsBuilder)
{
if (_httpClientFactory == null)
{
_handler = TestEnvironment.HttpMessageHandler
?? new HttpClientHandler
{
ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator
};
_httpClientFactory = () => new HttpClient(_handler, disposeHandler: false);
}
optionsBuilder
.ExecutionStrategy(d => new TestCosmosExecutionStrategy(d))
.RequestTimeout(TimeSpan.FromMinutes(20))
.HttpClientFactory(_httpClientFactory)
.ConnectionMode(ConnectionMode.Gateway);
return optionsBuilder;
}
}