public void GetMarketData_Invalid_Ticker()
        {
            // Arrange
            var request = new GetMarketData();

            request.DataSource = "GOOG";
            request.Ticker     = "AAPL";

            // Act
            var dataSource = _dataProvider.GetMarketData(request);

            // Assert
            Assert.False(dataSource.Success);
            Assert.AreEqual("Requested entity does not exist.", dataSource.ErrorMessage);
        }
        public object Get(GetMarketData request)
        {
            var response = new GetMarketDataResponse();

            try
            {
                if (string.IsNullOrEmpty(request.DataSource))
                {
                    throw new ArgumentNullException("request", "[DataSource] field is empty");
                }
                if (string.IsNullOrEmpty(request.Ticker))
                {
                    throw new ArgumentNullException("request", "[Ticker] field is empty");
                }

                var cache = _cachingManager.GetMarketData(request.ToJson());
                if (cache != null)
                {
                    return(cache);
                }
                else
                {
                    var result = _dataProvider.GetMarketData(request);
                    if (result.Success)
                    {
                        response.Success = true;
                        response.Data    = result.Data;
                        _cachingManager.Save(request.ToJson(), response);
                        _cachingManager.SaveCurrentChart("CurrentChart", request);
                    }
                    else
                    {
                        response.ResponseStatus = new ResponseStatus(string.Empty, result.ErrorMessage);
                    }
                }
            }
            catch (Exception ex)
            {
                var status = new ResponseStatus();
                status.Message    = ex.Message;
                status.ErrorCode  = ex.Source;
                status.StackTrace = ex.StackTrace;

                response.ResponseStatus = status;
            }

            return(response);
        }