public void WhenPluralIsAddedThenTemporaryDefinitionIsSetToSingular()
        {
            var word          = "sloths";
            var shortenedWord = "sloth";

            _wordDefinitionHelper.GetDefinitionForWord(shortenedWord).Returns(TestFileHelper.SlothTemporaryDefinition);
            _webDictionaryRequestHelper.MakeContentRequest(shortenedWord).Returns("sloth word forms plural sloths");
            _wordExistenceHelper.DoesWordExist(shortenedWord).Returns(true);

            _temporaryDefinitionHelper = new TemporaryDefinitionHelper(_fileHelper);
            var wordHelper = new WordHelper(_webDictionaryRequestHelper, _wordExistenceHelper, _wordDefinitionHelper, _fileHelper, _temporaryDefinitionHelper);

            wordHelper.StrippedSuffixDictionaryCheck(_dictionary, word);

            _wordService.UpdateDictionaryFile();

            _wordService.UpdateDictionaryFile();

            var json       = TestFileHelper.Read(Filename);
            var dictionary = JsonConvert.DeserializeObject <Dictionary>(json);

            dictionary.Words.Should().ContainEquivalentOf(new WordData
            {
                Word = "sloths",
                PermanentDefinition = null,
                TemporaryDefinition = TestFileHelper.SlothTemporaryDefinition,
                Status = WordStatus.Suffix
            });
        }
Exemplo n.º 2
0
        public bool CheckWordWithEndingExists(string word, string shortWord)
        {
            var responseText = _webDictionaryRequestHelper.MakeContentRequest(shortWord).ToLower();

            if (!responseText.Contains("word forms"))
            {
                return(false);
            }
            return(responseText.Contains(word));
        }
Exemplo n.º 3
0
        public void WhenWordHasOneLetterEnding()
        {
            var word = "cheeses";

            _webDictionaryRequestHelper
            .MakeContentRequest("cheese")
            .Returns("Word forms: there are some cheeses over there");

            var wordHelperUnderTest = new WordHelper(_webDictionaryRequestHelper, _wordExistenceHelper, _wordDefinitionHelper, _fileHelper, _temporaryDefinitionHelper);
            var response            = wordHelperUnderTest.StrippedSuffixDictionaryCheck(new Dictionary(), word);

            response.Should().BeTrue();
        }
Exemplo n.º 4
0
        public void WhenWordExistsResponseShouldBeTrue()
        {
            var word           = "ended";
            var responseString = "Word forms: There once was a sheep called Ollie, who jumped through the hedge by a lorry, the man hit the brakes, the sheep made mistakes, but all ended well and he's jolly";

            _webDictionaryRequestHelper
            .MakeContentRequest("end")
            .Returns(responseString);

            var wordHelper = new WordHelper(_webDictionaryRequestHelper, _wordExistenceHelper, _wordDefinitionHelper, _fileHelper, _temporaryDefinitionHelper);
            var response   = wordHelper.CheckWordWithEndingExists(word, "end");

            response.Should().BeTrue();
        }