private static int GetAnswer() { var count = 0; for (var i = start; i <= finish; i++) { string words; try { words = NumberToWords.Convert(i); } catch (ArgumentException ex) { Console.WriteLine("Error converting number to words: {0}", ex.Message); return(-1); } var letters = LetterCounter.Count(words); count += letters; if (verbose) { Console.WriteLine("{0} : {1} : {2}", words, letters, count); Thread.Sleep(step); } } return(count); }
static void Main(string[] args) { string sample = "aaabbc"; LetterCounter snample = new LetterCounter(); Console.WriteLine(snample.Count(sample)); Console.ReadLine(); }
public void CountShouldReturnTheNumberLettersAppearsInTheStringRegardlessOfCase() { var counter = new LetterCounter(); counter.Count("tesT").Should().BeEquivalentTo(new Dictionary<string, int> { ["T"] = 2, ["E"] = 1, ["S"] = 1 }); }
public static void Main(string[] args) { if (args.Length == 0) { throw new ArgumentException("No input provided", nameof(args)); } var counter = new LetterCounter(); var result = counter.Count(args[0]); var consoleTable = new ConsoleTable(); consoleTable.Options.EnableCount = false; var resultWriter = new ResultWriter(consoleTable); resultWriter.Write(result); Console.WriteLine( $"The text has been processed.{Environment.NewLine}Total letters counted: {args[0].Length}"); }
public void SentenceTest() { LetterCounter lc = new LetterCounter(); CollectionAssert.AreEqual(lc.Count("Happy birthday to you"), new char[] { ' ', 'y', 'a', 'h', 'o', 'p', 't', 'b', 'd', 'i', 'r', 'u' }); }
public void LargerTest() { LetterCounter lc = new LetterCounter(); CollectionAssert.AreEqual(lc.Count("abracadabra"), new char[] { 'a', 'b', 'r', 'c', 'd' }); }
public void LettersWithSameCountAreAlphabetical() { LetterCounter lc = new LetterCounter(); CollectionAssert.AreEqual(lc.Count("cabdpe"), new char[] { 'a', 'b', 'c', 'd', 'e', 'p' }); }
public void EmptyString() { LetterCounter lc = new LetterCounter(); CollectionAssert.AreEqual(lc.Count(""), new char[] { }); }
public void OneCharacterMultipleTimes() { LetterCounter lc = new LetterCounter(); CollectionAssert.AreEqual(lc.Count("aaa"), new char[] { 'a' }); }
public void OneCharacterOnce() { LetterCounter lc = new LetterCounter(); CollectionAssert.AreEqual(lc.Count("a"), new char[] { 'a' }); }
public void SimpleString() { LetterCounter lc = new LetterCounter(); CollectionAssert.AreEqual(lc.Count("aaabbc"), new char[] { 'a', 'b', 'c' }); }