forked from Marfusios/bitfinex-client-websocket
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BitfinexFileCommunicatorTests.cs
48 lines (41 loc) · 1.47 KB
/
BitfinexFileCommunicatorTests.cs
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Bitfinex.Client.Websocket.Client;
using Bitfinex.Client.Websocket.Files;
using Bitfinex.Client.Websocket.Responses.Trades;
using Xunit;
namespace Bitfinex.Client.Websocket.Tests.Integration
{
public class BitfinexFileCommunicatorTests
{
// ----------------------------------------------------------------
// Don't forget to decompress gzip files before starting the tests
// ----------------------------------------------------------------
[SkippableFact()]
public async Task OnStart_ShouldStreamMessagesFromFile()
{
var files = new[]
{
"data/bitfinex_raw_2018-11-12.txt"
};
foreach (var file in files)
{
var exist = File.Exists(file);
Skip.If(!exist, $"The file '{file}' doesn't exist. Don't forget to decompress gzip file!");
}
var trades = new List<Trade>();
var communicator = new BitfinexFileCommunicator();
communicator.FileNames = files;
communicator.Delimiter = ";;";
var client = new BitfinexWebsocketClient(communicator);
client.Streams.TradesStream.Subscribe(trade =>
{
trades.Add(trade);
});
await communicator.Start();
Assert.Equal(8938, trades.Count);
}
}
}