1
0
mirror of https://github.com/JKorf/CryptoExchange.Net.git synced 2026-08-13 01:12:59 +00:00

Unit tests updated

This commit is contained in:
JKorf
2018-12-03 14:56:24 +01:00
parent 64a66d4206
commit b4d45b4194
12 changed files with 394 additions and 254 deletions
@@ -0,0 +1,40 @@
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 Action 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()
{
return (TestSocket)CreateSocket(BaseAddress);
}
public CallResult<bool> ConnectSocketSub(SocketSubscription sub)
{
return ConnectSocket(sub).Result;
}
protected override bool SocketReconnect(SocketSubscription subscription, TimeSpan disconnectedTime)
{
OnReconnect?.Invoke();
return true;
}
}
}