Example #1
0
        public void GetSomeUserText_ReturnsSomeUserText_String()
        {
            // Arrange
            string newWords = "All work and no play makes Jack a dull boy.";
            // Console.WriteLine("Here are newWords: " + newWords);

            // Act
            WordSwap newText = new WordSwap(newWords);
            // Console.WriteLine("Here are your newText: " + newText);
            string result = newText.NewWords;

            // Console.WriteLine("Here are your result: " + result);

            // Assert
            Assert.AreEqual(newWords, result);
        }
Example #2
0
        /// <summary>
        /// Get all variations of a word and its replacement, including prefixes, suffixes, and prefixes with suffixes
        /// </summary>
        /// <param name="word"></param>
        /// <returns></returns>
        private static List <WordSwap> _wordWithPrefixesAndSuffixes(WordSwap word)
        {
            var allVariations = new List <WordSwap>();

            allVariations.Add(word); // Add the base word

            if (word.OptionalPrefixes != null && word.OptionalPrefixes.Count > 0)
            {
                foreach (var prefix in word.OptionalPrefixes) // Add all variations of prefixes
                {
                    allVariations.Add(new WordSwap
                    {
                        Word        = prefix + word.Word,
                        Replacement = prefix + word.Replacement,
                        CanBePlural = word.CanBePlural
                    });

                    if (word.OptionalSuffixes != null && word.OptionalSuffixes.Count > 0)
                    {
                        foreach (var suffix in word.OptionalSuffixes) // Add all variations of prefixes with suffixes
                        {
                            allVariations.Add(new WordSwap
                            {
                                Word        = prefix + word.Word + suffix,
                                Replacement = prefix + word.Replacement + suffix,
                                CanBePlural = word.CanBePlural
                            });
                        }
                    }
                }
            }

            if (word.OptionalSuffixes != null && word.OptionalSuffixes.Count > 0)
            {
                foreach (var suffix in word.OptionalSuffixes) // Add all variations of suffixes
                {
                    allVariations.Add(new WordSwap
                    {
                        Word        = word.Word + suffix,
                        Replacement = word.Replacement + suffix,
                        CanBePlural = word.CanBePlural
                    });
                }
            }

            return(allVariations);
        }
Example #3
0
 public void Dispose()
 {
     WordSwap.ClearAll();
 }