public void Parse_InputContainsTabsAndExtraSpaces_ParsesSuccessfully(string input)
        {
            // Arrange
            var parser         = new BigramTextParser(input);
            var expectedResult = new Dictionary <string, int>()
            {
                { "test case", 1 }
            };

            // Act
            var result = parser.Parse();

            // Assert
            Assert.IsTrue(EqualityChecks.
                          DictionariesAreEqual(result, expectedResult));
        }
        private void BtnParse_Click(object sender, RoutedEventArgs e)
        {
            lblHistogramResultMessage.Visibility = Visibility.Hidden;
            svResult.Visibility         = Visibility.Hidden;
            txtResult.Text              = "";
            lblPerformanceTimer.Content = "";

            Stopwatch sw = new Stopwatch();

            sw.Start();
            var parser = new BigramTextParser(txtInput.Text);
            var result = parser.Parse().OrderByDescending(x => x.Value);

            if (result.Any())
            {
                var sb = new StringBuilder();
                foreach (var bigram in result)
                {
                    sb.Append(bigram.Value);
                    sb.Append("\t");
                    sb.Append(bigram.Key.ToString());
                    sb.AppendLine();
                }

                txtResult.Text = sb.ToString();

                sw.Stop();

                svResult.Visibility = Visibility.Visible;

                lblPerformanceTimer.Content =
                    "Processing Time: " +
                    sw.Elapsed.Minutes + "m " +
                    sw.Elapsed.Seconds + "s " +
                    sw.Elapsed.Milliseconds + "ms";
            }
            else
            {
                lblHistogramResultMessage.Content    = "Sorry, no bigrams were found in the provided text!";
                lblHistogramResultMessage.Visibility = Visibility.Visible;
            }

            sw.Stop();
        }
        public void Parse_InputContainsPunctuations_ParsesSuccessfully(string input)
        {
            // Arrange
            var parser         = new BigramTextParser(input);
            var expectedResult = new Dictionary <string, int>()
            {
                { "test case", 1 },
                { "case pretty", 1 },
                { "pretty neat", 1 },
                { "neat huh", 1 }
            };

            // Act
            var result = parser.Parse();

            // Assert
            Assert.IsTrue(EqualityChecks.
                          DictionariesAreEqual(result, expectedResult));
        }
        public void Parse_InputContainsContractions_ParsesSuccessfully(string input)
        {
            // Arrange
            var parser         = new BigramTextParser(input);
            var expectedResult = new Dictionary <string, int>()
            {
                { "i haven't", 1 },
                { "haven't and", 1 },
                { "and can't", 1 },
                { "can't mr", 1 },
                { "mr o'reilly", 1 }
            };

            // Act
            var result = parser.Parse();

            // Assert
            Assert.IsTrue(EqualityChecks.
                          DictionariesAreEqual(result, expectedResult));
        }