Пример #1
0
            public void Parse_NullString_ReturnsDefaultObject()
            {
                ALittleAlliteration puzzle = new ALittleAlliteration(null);

                Assert.IsNull(puzzle.Solution);
                Assert.IsNull(puzzle.Clue);
            }
Пример #2
0
            public void ParsesUserInputCorrectly()
            {
                ALittleAlliteration puzzle = new ALittleAlliteration("Solution  =  Clue");

                Assert.AreEqual("Solution", puzzle.Solution);
                Assert.AreEqual("Clue", puzzle.Clue);

                Assert.AreEqual(@"	Solution			Sol		Clue		scheduled		", puzzle.GoogleSheetRow);
            }
Пример #3
0
            public void DuplicateWord_DoesNotAdd()
            {
                var currentWords = new List <string>()
                {
                    "any"
                };

                ALittleAlliteration.AddIfDistinct("any", currentWords);
                Assert.AreEqual(1, currentWords.Count);
            }
Пример #4
0
            public void Default_GeneratesExpectedText()
            {
                ALittleAlliteration aLittleAlliteration = new ALittleAlliteration();
                const string        EXPECTED_STRING     = @"

#HowToPlay: https://t.co/rSa0rUCvRC
";

                Assert.AreEqual(EXPECTED_STRING, aLittleAlliteration.GetTweet());
            }
Пример #5
0
            public void PopulatedObject_CreatesExpectedFile()
            {
                WeekOfPuzzles weekOfPuzzles = new WeekOfPuzzles {
                    Theme = "WeeklyTheme"
                };
                WordSquare mondayWordSquare = new WordSquare("_____")
                {
                    Clues = new [] { "first clue", "second clue", "third clue", "fourth clue", "fifth clue" },
                    Theme = "Theme"
                };

                mondayWordSquare.SetWordAtIndex("acorn", 0);
                mondayWordSquare.SetWordAtIndex("curio", 1);
                int indexToSet = 2;

                mondayWordSquare.SetWordAtIndex("orals", indexToSet);
                mondayWordSquare.SetWordAtIndex("rille", 3);
                mondayWordSquare.SetWordAtIndex("nosed", 4);

                weekOfPuzzles.MondayWordSquare = mondayWordSquare;

                VowelMovement tuesdayVowelMovementPuzzle = new VowelMovement("The MICE MISS their MOOSE.")
                {
                    InitialConsonant = "m",
                    FinalConsonant   = "s",
                    Theme            = "Theme"
                };

                weekOfPuzzles.TuesdayVowelMovement = tuesdayVowelMovementPuzzle;

                ALittleAlliteration wednesdayAlliterationPuzzle = new ALittleAlliteration()
                {
                    Clue     = "Convey vegetable automobile",
                    Solution = "carry carrot car",
                    Theme    = "VegetableWeek"
                };

                weekOfPuzzles.WednesdayALittleAlliteration = wednesdayAlliterationPuzzle;


                string fileName = $"EmptyObject_example_{Process.GetCurrentProcess().Id}.xml";

                if (File.Exists(fileName))
                {
                    File.Delete(fileName);
                }
                weekOfPuzzles.Serialize(fileName);

                var actualText = File.ReadAllText(fileName);

                Console.WriteLine(actualText);
                Assert.AreEqual(EXPECTED_TEXT, actualText);
            }
Пример #6
0
            public void Uppercase_BIL_ReturnsExpectedObject()
            {
                ALittleAlliteration aLittleAlliteration = new ALittleAlliteration();

                List <ALittleAlliteration> aLittleAlliterations = aLittleAlliteration.FindPuzzle("BIL");

                Assert.IsNotEmpty(aLittleAlliterations);
                aLittleAlliteration = aLittleAlliterations[0];
                Assert.AreEqual("billionaire's bile bill", aLittleAlliteration.Solution);
                // ReSharper disable StringLiteralTypo
                Assert.AreEqual("reciept for rich person's bodily fluid", aLittleAlliteration.Clue);
                // ReSharper restore StringLiteralTypo
            }
Пример #7
0
            public void Example_GeneratesExpectedText()
            {
                ALittleAlliteration aLittleAlliteration = new ALittleAlliteration
                {
                    Clue     = "What color was the emergency vehicle that was unexpectedly attacked?",
                    Solution = "Ambush Amber Ambulance"
                };
                const string EXPECTED_STRING = @"What color was the emergency vehicle that was unexpectedly attacked?

#HowToPlay: https://t.co/rSa0rUCvRC
";

                Assert.AreEqual(EXPECTED_STRING, aLittleAlliteration.GetTweet());
            }
Пример #8
0
            public void MUSIC_SeasonOne_IncludesExpectedPuzzle()
            {
                List <ALittleAlliteration> results = ALittleAlliteration.GetCluesForTheme("music", 1);
                bool foundExpectedPuzzle           = false;

                foreach (var puzzle in results)
                {
                    if (puzzle.Solution == "abbreviate ABBA's abbot")
                    {
                        foundExpectedPuzzle = true;
                        break;
                    }
                }
                Assert.IsTrue(foundExpectedPuzzle, "Did not find expected puzzle.");
            }
Пример #9
0
            public void BIRD_IncludesExpectedPuzzle()
            {
                List <ALittleAlliteration> results = ALittleAlliteration.GetCluesForTheme("bird");
                bool foundExpectedPuzzle           = false;

                foreach (var puzzle in results)
                {
                    if (puzzle.Solution == "avid aviatrix's aviary")
                    {
                        foundExpectedPuzzle = true;
                        break;
                    }
                }
                Assert.IsTrue(foundExpectedPuzzle, "Did not find expected puzzle.");
            }
Пример #10
0
 public void Deserialize(string fileName)
 {
     using (TextReader reader = new StreamReader(fileName))
     {
         if (_xmlSerializer.Deserialize(reader) is WeekOfPuzzles deserializedPuzzles)
         {
             MondayWordSquare             = deserializedPuzzles.MondayWordSquare;
             TuesdayVowelMovement         = deserializedPuzzles.TuesdayVowelMovement;
             WednesdayALittleAlliteration = deserializedPuzzles.WednesdayALittleAlliteration;
             ThursdayVowelMovement        = deserializedPuzzles.ThursdayVowelMovement;
             FridayALittleAlliteration    = deserializedPuzzles.FridayALittleAlliteration;
             SelectedWords      = deserializedPuzzles.SelectedWords;
             Theme              = deserializedPuzzles.Theme;
             MondayOfWeekPosted = deserializedPuzzles.MondayOfWeekPosted;
         }
     }
 }
Пример #11
0
            public void BOO_ExcludesClueWithDate()
            {
                ALittleAlliteration aLittleAlliteration = new ALittleAlliteration();

                List <ALittleAlliteration> aLittleAlliterations = aLittleAlliteration.FindPuzzle("boo");

                bool foundPuzzleThatShouldHaveBeenExcluded = false;

                foreach (var puzzle in aLittleAlliterations)
                {
                    if (puzzle.Solution == "boost boo books")
                    {
                        foundPuzzleThatShouldHaveBeenExcluded = true;
                    }
                }
                Assert.IsFalse(foundPuzzleThatShouldHaveBeenExcluded);
            }
Пример #12
0
            public void BLI_ExcludesClueWithTwitterUrl()
            {
                ALittleAlliteration aLittleAlliteration = new ALittleAlliteration();

                List <ALittleAlliteration> aLittleAlliterations = aLittleAlliteration.FindPuzzle("bli");

                bool foundPuzzleThatShouldHaveBeenExcluded = false;

                foreach (var puzzle in aLittleAlliterations)
                {
                    if (puzzle.Solution == "Blitz blinding bliss")
                    {
                        foundPuzzleThatShouldHaveBeenExcluded = true;
                    }
                }
                Assert.IsFalse(foundPuzzleThatShouldHaveBeenExcluded);
            }
Пример #13
0
            public void CHI_ReturnsExpectedResults()
            {
                ALittleAlliteration alliteration = new ALittleAlliteration();
                var words = alliteration.FindWordsThatStartWith("chi", out _);

                Console.WriteLine("--------------");
                foreach (string word in words)
                {
                    Console.WriteLine(word);
                }
                Assert.IsTrue(words.Contains("child"), "Expected 'child' to be included.");

                Assert.IsFalse(words.Contains("chips"), "Expected 'chips' to be excluded.");
                // ReSharper disable StringLiteralTypo
                Assert.IsFalse(words.Contains("chil"), "Expected 'chil' to be excluded.");
                // ReSharper restore StringLiteralTypo
                Assert.IsFalse(words.Contains("childish"), "Expected 'childish' to be excluded.");
                Assert.IsFalse(words.Contains("chives"), "Expected 'chives' to be excluded.");
            }
Пример #14
0
            public void Removes_Ful_Ending()
            {
                const string ROOT_WORD    = "art";
                const string DERIVED_WORD = "artful";

                var currentWords = new List <string>()
                {
                    ROOT_WORD
                };

                ALittleAlliteration.AddIfDistinct(DERIVED_WORD, currentWords);
                Assert.AreEqual(1, currentWords.Count);
                Assert.AreEqual(ROOT_WORD, currentWords[0]);

                currentWords = new List <string>()
                {
                    DERIVED_WORD
                };
                ALittleAlliteration.AddIfDistinct(ROOT_WORD, currentWords);
                Assert.AreEqual(1, currentWords.Count);
                Assert.AreEqual(ROOT_WORD, currentWords[0]);
            }
Пример #15
0
            public void EndingWithY_RemovesIES()
            {
                const string ROOT_WORD    = "artery";
                const string DERIVED_WORD = "arteries";

                var currentWords = new List <string>()
                {
                    ROOT_WORD
                };

                ALittleAlliteration.AddIfDistinct(DERIVED_WORD, currentWords);
                Assert.AreEqual(1, currentWords.Count);
                Assert.AreEqual(ROOT_WORD, currentWords[0]);

                currentWords = new List <string>()
                {
                    DERIVED_WORD
                };
                ALittleAlliteration.AddIfDistinct(ROOT_WORD, currentWords);
                Assert.AreEqual(1, currentWords.Count);
                Assert.AreEqual(ROOT_WORD, currentWords[0]);
            }
Пример #16
0
            public void DoubleEndingExample()
            {
                const string ROOT_WORD    = "chip";
                const string DERIVED_WORD = "chipped";

                var currentWords = new List <string>()
                {
                    ROOT_WORD
                };

                ALittleAlliteration.AddIfDistinct(DERIVED_WORD, currentWords);
                Assert.AreEqual(1, currentWords.Count);
                Assert.AreEqual(ROOT_WORD, currentWords[0]);

                currentWords = new List <string>()
                {
                    DERIVED_WORD
                };
                ALittleAlliteration.AddIfDistinct(ROOT_WORD, currentWords);
                Assert.AreEqual(1, currentWords.Count);
                Assert.AreEqual(ROOT_WORD, currentWords[0]);
            }
Пример #17
0
            public void SEA_DoesNotThrow()
            {
                ALittleAlliteration aLittleAlliteration = new ALittleAlliteration();

                aLittleAlliteration.FindPuzzle("sea");
            }
Пример #18
0
            public void NoWords_ReturnsEmptySet()
            {
                ALittleAlliteration alliteration = new ALittleAlliteration();

                Assert.AreEqual(0, alliteration.FindWordsThatStartWith("aaa", out _).Count);
            }