mirror of
				https://github.com/JKorf/CryptoExchange.Net
				synced 2025-10-31 10:27:48 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			41 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			41 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using System;
 | |
| using CryptoExchange.Net.Interfaces;
 | |
| using CryptoExchange.Net.Logging;
 | |
| using CryptoExchange.Net.Objects;
 | |
| using CryptoExchange.Net.Sockets;
 | |
| using Moq;
 | |
| 
 | |
| namespace CryptoExchange.Net.UnitTests.TestImplementations
 | |
| {
 | |
|     public class TestSocketClient: SocketClient
 | |
|     {
 | |
|         public Func<bool> OnReconnect { get; set; }
 | |
| 
 | |
|         public TestSocketClient() : this(new SocketClientOptions())
 | |
|         {
 | |
|         }
 | |
| 
 | |
|         public TestSocketClient(SocketClientOptions exchangeOptions) : base(exchangeOptions, exchangeOptions.ApiCredentials == null ? null : new TestAuthProvider(exchangeOptions.ApiCredentials))
 | |
|         {
 | |
|             SocketFactory = new Mock<IWebsocketFactory>().Object;
 | |
|             Mock.Get(SocketFactory).Setup(f => f.CreateWebsocket(It.IsAny<Log>(), It.IsAny<string>())).Returns(new TestSocket());
 | |
|         }
 | |
| 
 | |
|         public TestSocket CreateSocket()
 | |
|         {
 | |
|             Mock.Get(SocketFactory).Setup(f => f.CreateWebsocket(It.IsAny<Log>(), It.IsAny<string>())).Returns(new TestSocket());
 | |
|             return (TestSocket)CreateSocket(BaseAddress);
 | |
|         }
 | |
| 
 | |
|         public CallResult<bool> ConnectSocketSub(SocketSubscription sub)
 | |
|         {
 | |
|             return ConnectSocket(sub).Result;
 | |
|         }
 | |
|         
 | |
|         protected override bool SocketReconnect(SocketSubscription subscription, TimeSpan disconnectedTime)
 | |
|         {
 | |
|             return OnReconnect.Invoke();
 | |
|         }
 | |
|     }
 | |
| }
 |