Example #1
0
        public void ShouldCountTokenOccurancesInSingleLine()
        {
            //Assign

            var mock = new Mock <ILogger>();

            var grep = new Grep(new[]
            {
                "marxk",
                "szymoxkn",
                "szyxmon",
                "sxkzyxmon",
                "sxkzyxmo nx xk xk",
                "",
                " ",
                "\\n",
            }, mock.Object);

            const string token = "xk";

            //Act

            int result = grep.CountTokenOccurancesInAllLines(token);

            //Assert
            Assert.AreEqual(6, result);
        }
 public void Run()
 {
     grep = new Grep(new Downloader().DownloadWebpageAsText(argsList.URL));
     if (argsList.CountWords)
     {
         Console.WriteLine("Occurances of a given word in all lines:");
         Console.WriteLine(grep.CountTokenOccurancesInAllLines(argsList.Word));
     }
     if (argsList.SearchWord)
     {
         Console.WriteLine("Lines where the given word occure:");
         Console.WriteLine(grep.GetLinesContainingSpecifiedToken(argsList.Word));
     }
 }