Example #1
0
        private void buttonGenerate_Click(object sender, RoutedEventArgs e)
        {
            string resultString = string.Empty;

            try
            {
                if (radioSentence.IsChecked.Value)
                {
                    resultString = _gen.GenerateSentence(Convert.ToInt32(textSentence_MinWords.Text));
                }
                else if (radioWords.IsChecked.Value)
                {
                    resultString = _gen.GenerateWords(Convert.ToInt32(textWords_NumWords.Text));
                }
                else if (radioTitle.IsChecked.Value)
                {
                    resultString = _gen.GenerateTitle(Convert.ToInt32(textTitle_NumWords.Text));
                }
                else if (radioParagraphs.IsChecked.Value)
                {
                    resultString = _gen.GenerateParagraphs(Convert.ToInt32(textParagraphs_NumParagraphs.Text));
                }
                else
                {
                    throw new NotImplementedException();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
            }
            textOutput.Text = resultString;
        }
        public void T_GenerateTitle_Length_And_Capitalization()
        {
            GeneratorFacade facade         = InitBaseFacade();
            string          resultingTitle = facade.GenerateTitle(9);

            string[] words = resultingTitle.Split(' ');
            Assert.AreEqual(9, words.Length);
            foreach (string word in words)
            {
                Assert.IsTrue(char.IsUpper(word[0]));
            }
        }