Beispiel #1
0
        public static void Main(string[] args)
        {
            Logger          logger          = new Logger();
            RemoteURLReader remoteURLReader = new RemoteURLReader();
            StockAPIService stockAPIService = new StockAPIService(remoteURLReader);
            Trader          trader          = new Trader(stockAPIService, logger);

            TradingApp app = new TradingApp(trader, logger);

            app.Start();
        }
Beispiel #2
0
        public static void Main(string[] args)
        {
            ILogger     logger     = new Logger();
            IUrlReader  urlReader  = new RemoteURLReader();
            IApiService apiService = new StockAPIService(urlReader);
            ITrader     trader     = new Trader(logger, apiService);

            TradingApp app = new TradingApp(logger, trader, urlReader, apiService);

            app.Start();
        }
        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);
        }
Beispiel #4
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));
        }
Beispiel #5
0
 public StockAPIService(RemoteURLReader remoteURLReader)
 {
     _remoteURLReader = remoteURLReader;
 }
Beispiel #6
0
 public void SetUp()
 {
     remoteURLReader = Substitute.For <RemoteURLReader>();
     stockAPIService = new StockAPIService(remoteURLReader);
 }