Beispiel #1
0
        public void PricesTickThroughForSpecificCurrencyPair()
        {
            var knownCurrencies = _sut.KnownCurrencies;

            var currencyPairIdentifier = knownCurrencies.First();

            var priceStream = _sut.GetPricesFor(currencyPairIdentifier);

            var fxRates     = new List <FxRate>();
            var resetHandle = new AutoResetEvent(false);

            _subscription = priceStream.Buffer(5).Take(1).Subscribe(x =>
            {
                fxRates.AddRange(x);
                if (fxRates.Count >= 5)
                {
                    resetHandle.Set();
                }
            });

            resetHandle.WaitOne(TimeSpan.FromSeconds(5));

            Assert.That(fxRates, Has.Count.EqualTo(5));
            Assert.That(fxRates.All(x => x.CurrencyPair.Equals(currencyPairIdentifier)), Is.True);
        }
Beispiel #2
0
        public void Visit(FxRateTerm fxRateTerm)
        {
            var priceStream = _fxRateRepository
                              .GetPricesFor(fxRateTerm.Identifier)
                              .Select(x =>
            {
                fxRateTerm.SetValue(x.Rate);
                return(fxRateTerm);
            });

            _terms.Add(priceStream);
        }