public int GetBytesCount(string sentence) { int bytesCount; try { Console.WriteLine("Starting second crawler..."); var bytesFromPage = _crawlerService .GoToUrl(SECOND_CRAWLER_URL + sentence) .GetTextContentFromElement("#bytes"); bytesCount = int.Parse(bytesFromPage.Split(" ")[0]); Console.WriteLine("Second crawler successfully completed..."); } catch (CrawlerException) { bytesCount = BytesService.CountFromString(sentence); } finally { _crawlerService.Quit(); } return(bytesCount); }
public Report(string fileName, long fileSize, string path, int iterations, TimeSpan totalTime, TimeSpan averageTime) { FileName = fileName; FileSize = BytesService.ConvertBytesToMegabytes(fileSize) + "mb"; Path = path; Iterations = iterations; TotalTime = totalTime; AverageTime = averageTime; }
public override long GetValue() { return(BytesService.ConvertMegabytesToBytes((long)_value)); }
public void Should_count_from_string_correctly() { Assert.Equal(4, BytesService.CountFromString("test")); }
public void Should_throw_ArgumentNullException_when_converting_bytes_to_megabytes_and_argument_is_lesser_than_zero() { Assert.Throws <ArgumentException>(() => BytesService.ConvertBytesToMegabytes(-1)); }
public void Should_convert_bytes_to_megabytes_correctly() { Assert.Equal(10L, BytesService.ConvertBytesToMegabytes(10485760)); }
public void Should_throw_ArgumentNullException_when_converting_string_to_bytes_and_argument_is_null() { Assert.Throws <ArgumentException>(() => BytesService.StringToBytes(null)); }
public void Should_return_byte_array_from_string_correctly() { Assert.Equal(new byte[4] { 116, 101, 115, 116 }, BytesService.StringToBytes("test")); }
public void Should_throw_ArgumentNullException_when_counting_from_string_and_argument_is_null() { Assert.Throws <ArgumentException>(() => BytesService.CountFromString(null)); }