public async void ShouldReceiveExecutedTradeInAnalytics()
{
var pass = false;
var testCcyPair = "XXXXXA";
_analyticsServiceInstance = await _heartbeatStream
.Where(hb => hb.Type == ServiceTypes.Analytics)
.Select(hb => hb.Instance)
.Take(1);
// this is the callback when the analytics svc receives the executed trade notification
Action<dynamic> analyticsCallbackAssertion = d =>
{
foreach (var dto in d)
{
foreach (var currentPosition in dto.CurrentPositions)
{
if (currentPosition.Symbol == testCcyPair)
{
Console.WriteLine(currentPosition);
// set the assertion
pass = true;
_timeoutCancellationTokenSource.Cancel(false);
}
}
}
};
await _channel.RealmProxy.TopicContainer
.GetTopicByUri(AnalyticsUpdatesReplyTo)
.Subscribe(new WampSubscriber(analyticsCallbackAssertion), new SubscribeOptions());
// subscribe to analytics with the callback
_channel.RealmProxy.RpcCatalog.Invoke(
new RpcCallback(() => { }),
new CallOptions(),
$"{_analyticsServiceInstance}.getAnalytics",
new object[] {new {ReplyTo = AnalyticsUpdatesReplyTo, Payload = new NothingDto()}});
// call execute trade
await CallExecuteTrade(testCcyPair);
Assert.True(pass);
}