Exemplo n.º 1
0
        public void GetSynonyms_ForIncorrect_IsEmpty(string input)
        {
            IEnumerable <string> resultForIncorrect = new List <string>();

            var realResult = thesaurus.GetSynonyms(input);

            Assert.Empty(realResult);
        }
        public void AddSynonyms(string testWord)
        {
            List <string> synonymsInput  = new List <string>();
            List <string> synonymsOutput = new List <string>();

            // All words must be in lower case only for the comparison, because the AddSynonyms-function converts the words to lower case
            // before storing to database to avoid duplicates. So, it is possible to use upper case letters when storing to database but they will be converted
            // to lower case
            testWord = testWord.ToLower();
            synonymsInput.Add(testWord);
            int amountOfSynonyms = 4;

            for (int i = 1; i < amountOfSynonyms; i++)
            {
                synonymsInput.Add(testWord + i);
            }
            mockObject.AddSynonyms(synonymsInput);
            synonymsOutput = (List <string>)mockObject.GetSynonyms(testWord);
            // synonymsOutput + testWord should be the same as synonymsInput
            synonymsOutput.Add(testWord);
            result = Compare(synonymsInput, synonymsOutput);

            Assert.True(result.Value, result.Message);
        }
Exemplo n.º 3
0
        public void AddSynonymsOneAddition()
        {
            var inputList = new List <string> {
                "C#"
            };

            _thesaurus.AddSynonyms(inputList);

            var words    = _thesaurus.GetWords();
            var synonyms = _thesaurus.GetSynonyms(inputList[0]);

            Assert.Equal(1, words.Count());
            Assert.Equal(0, synonyms.Count());
            Assert.Contains("C#", words);
            Assert.Contains(inputList[0], words.ToList()[0]);
            Assert.Equal(inputList, words); // Order is important
        }