Files
csharp/tests/KubernetesClient.Tests/Mock/MockWebSocketBuilder.cs
Boshi Lian 655a42c6bd add tcp keep alive hack to net5 target (#560)
* add tcp keep alive hack to net5 target

* remove unused code

* fix ep

* Update buildtest.yaml

* fix netstandard21

* fix space

* fix net5 warning

* more comment
2021-03-11 09:32:22 -08:00

47 lines
1.3 KiB
C#

#if !NETSTANDARD2_1 || NET5_0
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Net.WebSockets;
using System.Security.Cryptography.X509Certificates;
using System.Threading;
using System.Threading.Tasks;
namespace k8s.Tests.Mock
{
public class MockWebSocketBuilder : WebSocketBuilder
{
public Dictionary<string, string> RequestHeaders { get; }
= new Dictionary<string, string>();
public Collection<X509Certificate2> Certificates { get; }
= new Collection<X509Certificate2>();
public Uri Uri { get; private set; }
public WebSocket PublicWebSocket => this.WebSocket;
public override WebSocketBuilder AddClientCertificate(X509Certificate2 certificate)
{
this.Certificates.Add(certificate);
return this;
}
public override Task<WebSocket> BuildAndConnectAsync(Uri uri, CancellationToken cancellationToken)
{
this.Uri
= uri;
return Task.FromResult(this.PublicWebSocket);
}
public override WebSocketBuilder SetRequestHeader(string headerName, string headerValue)
{
this.RequestHeaders.Add(headerName, headerValue);
return this;
}
}
}
#endif // !NETSTANDARD2_1 || NET5_0