Beispiel #1
0
        public void It_Will_Only_Return_Words_Of_The_Specified_Length()
        {
            // Arrange
            var rawDictionary = new[]
            {
                "1",
                "22",
                "333",
                "4444",
                "four",
                "55555"
            };

            var expected = new[]
            {
                "4444",
                "four"
            };

            var dictionaryProvider = Substitute.For <IDictionaryProvider>();

            dictionaryProvider.GetWords().Returns(rawDictionary);
            var sut = new FixedLengthDictionaryProvider(dictionaryProvider, 4);

            // Act
            var actual = sut.GetWords();

            // Assert
            actual.Should().BeEquivalentTo(expected, "These are the only four letter words");
        }
Beispiel #2
0
        public IDictionaryProvider ResolveDictionaryProvider(string dictionaryFilePath)
        {
            IApplicationConfiguration applicationConfiguration = ResolveApplicationConfiguration();
            IDictionaryProvider       dictionaryProvider       = new TextFileDictionaryProvider(dictionaryFilePath);

            if (applicationConfiguration.DictionaryWordAllowedLength.HasValue)
            {
                dictionaryProvider = new FixedLengthDictionaryProvider(dictionaryProvider, applicationConfiguration.DictionaryWordAllowedLength.Value);
            }

            return(dictionaryProvider);
        }