Beispiel #1
0
            public void IfNoValidCombinationsExist_ReturnsEmptyResult()
            {
                _wordsIndex = new FakeWordsIndex(Enumerable.Empty <Word>());
                var actual = _sut.FindAllPossibleCombinationsOfLength(_wordsIndex, _desiredLength).ToList();

                Assert.That(actual, Is.Not.Null);
                Assert.That(actual, Is.Empty);
            }
            public void GivenWordList_FindsValidCombinations()
            {
                var allWords = new[] {
                    new Word("albums"),
                    new Word("al"),
                    new Word("u"),
                    new Word("ticket"),
                    new Word("foul"),
                    new Word("be"),
                    new Word("befoul"),
                    new Word("magazine"),
                    new Word("bums"),
                    new Word("trump")
                };

                var wordsIndex = new FakeWordsIndex(allWords);

                A.CallTo(() => _wordsIndexFactory.Create(allWords)).Returns(wordsIndex);

                var allPossibleCombinations = new[] {
                    new WordCombination(new Word("al"), new Word("bums")),
                    new WordCombination(new Word("be"), new Word("foul")),
                    new WordCombination(new Word("al"), new Word("foul")),
                    new WordCombination(new Word("be"), new Word("bums")),
                    new WordCombination(new Word("u"), new Word("trump")),
                    new WordCombination(new Word("bums"), new Word("al")),
                    new WordCombination(new Word("foul"), new Word("be")),
                    new WordCombination(new Word("foul"), new Word("al")),
                    new WordCombination(new Word("bums"), new Word("be")),
                    new WordCombination(new Word("trump"), new Word("u"))
                };

                A.CallTo(() => _allPossibleCombinationsFinder.FindAllPossibleCombinationsOfLength(wordsIndex, _desiredLength))
                .Returns(allPossibleCombinations);

                var validCombinations = new[] {
                    new WordCombination(new Word("al"), new Word("bums")),
                    new WordCombination(new Word("be"), new Word("foul"))
                };
                var wordsWithRequestedLength = wordsIndex.GetWordsOfLength(_desiredLength);

                A.CallTo(() => _wordCombinationFilter.FilterByListOfPossibleWords(allPossibleCombinations, A <IEnumerable <Word> > .That.IsSameSequenceAs(wordsWithRequestedLength)))
                .Returns(validCombinations);

                var actual = _sut.FindCombinations(allWords);

                Assert.That(actual, Is.EquivalentTo(validCombinations));
            }