Example #1
0
        public void GetStreamReader_WhenCorrect_ShouldReturnNewReader()
        {
            //Act
            var result = _sut.GetStreamReader("./appsettings.json");

            //Assert
            Assert.Equal(result.GetType(), System.Type.GetType("System.IO.StreamReader"));
        }
        private async Task <string> TwitterApiRequest(string resourceUrl, List <string> parameterlist)
        {
            ServicePointManager.Expect100Continue = false;

            string postBody;

            if (parameterlist != null)
            {
                postBody = GetPostBody(parameterlist);
            }
            else
            {
                postBody = string.Empty;
            }

            resourceUrl += "?" + postBody;

            var request = (HttpWebRequest)WebRequest.Create(resourceUrl);

            request.Headers.Add("Authorization", this.OAuthHeader);
            request.Method      = "GET";
            request.ContentType = "application/x-www-form-urlencoded";

            var response = await request.GetResponseAsync();

            var responseData = streamReaderWrapper.GetStreamReader(response);

            return(responseData);
        }
Example #3
0
        public async Task AnalyzeFile(FileInfo file)
        {
            try{
                var lot = new Lot.Lot(_lotconfiguration, file.Name);

                using (System.IO.StreamReader sr = _streamReader.GetStreamReader(file.FullName))
                {
                    string s;
                    int    currentLine = 0;
                    while ((s = sr.ReadLine()) != null)
                    {
                        //We need to abstract this information to handle better and log if some information is not correct.
                        try{
                            lot.AddData(s);
                        }catch (System.Exception e) {
                            _logger.Warning("Problem in line " + currentLine + " in the lot " + file.Name + " : " + e.Message);
                        }

                        currentLine++;
                    }
                }

                await _reportGeneratorService.GenerateReport(lot);
            }catch (IOException e) {
                _logger.Warning("Error ocurred when opening lot:" + e.Message);
                throw e;
            }
        }