public void ByLenght_should_count_word_by_length() { var(_, byLenght) = WordCounter.Do("I have a transportation device which is a red bike which I love to ride."); byLenght.Should().BeEquivalentTo(new Dictionary <int, int> { { 1, 4 }, { 2, 2 }, { 3, 1 }, { 4, 4 }, { 5, 2 }, { 6, 1 }, { 14, 1 }, }); }
public void ByWord_should_count_words() { var(byWord, _) = WordCounter.Do("I have a transportation device which is a red bike which I love to ride."); byWord.Should().BeEquivalentTo(new Dictionary <string, int> { { "I", 2 }, { "have", 1 }, { "a", 2 }, { "transportation", 1 }, { "device", 1 }, { "which", 2 }, { "is", 1 }, { "red", 1 }, { "bike", 1 }, { "love", 1 }, { "to", 1 }, { "ride", 1 }, }); }
public static void Main(string[] args) { var(byWord, byLenght) = WordCounter.Do("I have a transportation device which is a red bike which I love to ride."); Console.WriteLine("First task:"); Console.WriteLine("byWord:"); Console.WriteLine(string.Join("\r\n", byWord.Select(x => $"{x.Key}={x.Value}"))); Console.WriteLine(); Console.WriteLine("byLenght:"); Console.WriteLine(string.Join("\r\n", byLenght.Select(x => $"{x.Key}={x.Value}"))); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("Second task:"); Console.WriteLine("Hello World!"); var r = StringReverser.Do("Hello World!"); Console.WriteLine(r); }