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 void Should_count_from_string_correctly() { Assert.Equal(4, BytesService.CountFromString("test")); }
public void Should_throw_ArgumentNullException_when_counting_from_string_and_argument_is_null() { Assert.Throws <ArgumentException>(() => BytesService.CountFromString(null)); }