예제 #1
0
        public void Solve_WordTooShort()
        {
            WordPuzzle wordPuzzle = new WordPuzzle("bomen");
            var        result     = wordPuzzle.Solve("bome");

            char[] expectedLetters = "bome.".ToCharArray();

            CollectionAssert.AreEqual(expectedLetters, result.LetterEntries.Select(x => x.Letter));
            Assert.IsTrue(result.LetterEntries.All(x => x.State == LetterState.DoesNotExistInWord));
        }
예제 #2
0
        public void Solve_LetterInIncorrectLocationIsOnlySetToIncorrectLocationNTimesItExistsInTheWord()
        {
            WordPuzzle wordPuzzle = new WordPuzzle("yxxyy");
            var        result     = wordPuzzle.Solve("zzxxx");

            char[]        expectedLetters = "zzxxx".ToCharArray();
            LetterState[] expectedStates  = new LetterState[]
            {
                LetterState.DoesNotExistInWord,
                LetterState.DoesNotExistInWord,
                LetterState.CorrectLocation,
                LetterState.IncorrectLocation,
                LetterState.DoesNotExistInWord,
            };

            CollectionAssert.AreEqual(expectedLetters, result.LetterEntries.Select(x => x.Letter));
            CollectionAssert.AreEqual(expectedStates, result.LetterEntries.Select(x => x.State));
        }
예제 #3
0
        public void Solve_InCorrectWord()
        {
            WordPuzzle wordPuzzle = new WordPuzzle("bomen");
            var        result     = wordPuzzle.Solve("clown");

            char[]        expectedLetters = "clown".ToCharArray();
            LetterState[] expectedStates  = new LetterState[]
            {
                LetterState.DoesNotExistInWord,
                LetterState.DoesNotExistInWord,
                LetterState.IncorrectLocation,
                LetterState.DoesNotExistInWord,
                LetterState.CorrectLocation,
            };

            CollectionAssert.AreEqual(expectedLetters, result.LetterEntries.Select(x => x.Letter));
            CollectionAssert.AreEqual(expectedStates, result.LetterEntries.Select(x => x.State));
        }