Esempio n. 1
0
        public async void ShouldReceiveExecutedTradeInBlotter()
        {
            const string testCcyPair    = "XXXXXB";
            var          asyncAssertion = new TaskCompletionSource <bool>();

            // this is the callback when the blotter receives the executed trade notification
            void BlotterCallbackAssertion(dynamic d)
            {
                foreach (var trade in d.Trades)
                {
                    if (trade.CurrencyPair == testCcyPair && trade.Status == "Done")
                    {
                        Console.WriteLine(d);
                        // set the assertion
                        asyncAssertion.SetResult(true);
                        return;
                    }
                }
            }

            await _broker.RpcCall <dynamic, NothingDto>(ServiceTypes.Blotter, "getTradesStream", new NothingDto(), BlotterCallbackAssertion);

            await CallExecuteTrade(testCcyPair);

            var pass = await asyncAssertion.Task.ToObservable().Timeout(ResponseTimeout, Observable.Return(false)).Take(1);

            Assert.True(pass);
        }
Esempio n. 2
0
        public async void ShouldContainSomeReferenceData()
        {
            var pass = false;
            var timeoutCancellationTokenSource = new CancellationTokenSource();

            var broker = new TestBroker();

            await broker.RpcCall <CurrencyPairUpdatesDto, NothingDto>(ServiceTypes.Reference, "getCurrencyPairUpdatesStream", new NothingDto(), dto =>
            {
                foreach (var x in dto.Updates)
                {
                    Console.WriteLine(x);
                }

                pass = true;
                timeoutCancellationTokenSource.Cancel(false);
            });

            try
            {
                await Task.Delay(ResponseTimeout, timeoutCancellationTokenSource.Token);

                _testOutputHelper.WriteLine($"Test timed out after {ResponseTimeout.TotalSeconds} seconds");
            }
            catch (TaskCanceledException)
            {
            }

            Assert.True(pass);
        }