public static StockAPIService Instance()
        {
            if (_instance == null)
            {
                //string apiPath = "https://financialmodelingprep.com/api/v3/stock/real-time-price/{0}";
                string apiPath = "http://www.test.com/{0}";
                var    reader  = RemoteURLReader.Instance();
                _instance = new StockAPIService(apiPath, reader);
            }

            return(_instance);
        }
예제 #2
0
        [Test] // readFromURL threw an exception
        public void TestGetPriceServerDown()
        {
            ////arrange
            //_reader.ReadFromUrl("http://www.test.com/{0}").Returns(x => { throw new Exception(); });
            //var aPIService = StockAPIService.Instance();
            //string symbol = "aapl";
            RemoteURLReader reader = RemoteURLReader.Instance();
            string          url    = @"http://www.test.com";

            ////act
            //aPIService.Reader = _reader;
            //aPIService.APIPath = "http://www.test.com/{0}";

            ////assert
            //Assert.Throws<Exception>(()=> aPIService.GetPrice(symbol));
            Assert.Throws <WebException>(() => reader.ReadFromUrl(url));
        }