コード例 #1
0
        public void given_market_center_is_open_process_response()
        {
            var url = WebUtility.UrlEncode("https://query.yahooapis.com/v1/public/yql?q=select * from yahoo.finance.xchange where pair in ('AUDCAD,AUDCHF')") + "&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys";
            var pairs = new List<CurrencyPair>
            {
                new CurrencyPair {Symbol = "AUDCAD"},
                new CurrencyPair {Symbol = "AUDCHF"}
            };

            var response = new Quote
            {
                Created = DateTime.Now,
                Rates = new List<Rate>()
            };

            response.Rates.Add(new Rate { CurrencyPair = new CurrencyPair { Symbol = "AUDCAD" } });
            response.Rates.Add(new Rate { CurrencyPair = new CurrencyPair { Symbol = "AUDCHF" } });

            _currencyPairProvider.Setup(x => x.Market).Returns(new Market{IsOpen = true});
            _currencyPairProvider.Setup(x => x.Pairs).Returns(pairs);
            _httpProvider.Setup(x => x.GetAsync(url, _formatter.Object)).Returns(Task.FromResult(response));

            _yahooFinance = new YahooFinanceProvider(_httpProvider.Object,
                                                                    _currencyPairProvider.Object,
                                                                    _formatter.Object);
            var result =_yahooFinance.GetQuote();

            _httpProvider.Verify();
        }
コード例 #2
0
        public void given_valid_request_process_test_successfully()
        {
            var quote = new Quote();

            _dataRepository.SetupGet(x => x.Quotes).Returns(_collection.Object);

            _provider.Setup(x => x.GetQuote()).Returns(Task.FromResult(quote));

            _sut = new GetQuotes(_provider.Object, _log.Object, _dataRepository.Object);

            _sut.Execute(_context.Object);

            _collection.Verify(x => x.InsertOne(quote, null, CancellationToken.None));
        }